From patchwork Tue Dec 24 20:04:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3585E7718D for ; Tue, 24 Dec 2024 20:06:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9o-0002kP-8p; Tue, 24 Dec 2024 15:05:32 -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 1tQB9i-0002jE-Fr for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:26 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9g-0002Ud-Sh for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:26 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2166360285dso57544885ad.1 for ; Tue, 24 Dec 2024 12:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070723; x=1735675523; 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=+v7eNfvrqQSZE5BwDanDqUsLKy4GSW+67YoWGKlQXJ4=; b=NZ1TpG3XefX4+yahtm2rKAHsAgCFQQfi3/2BYhmdRSZuG3Xp8cIualiwE2pyABvbvg LezyPHKOyczli27mnNGmLaYKsOpGpPG1+O9LWJpU4yo4cqtnj1To1fodCWrS+8ahj8FF WpQPHp/9fVthfu/dSjVNjy6Qqgftq+4uNq21qyyH+VG1ttzl3H0chq8VfpND3MBU8OFH lkO2E/7sn+vXmUI1nKn5QBuvFwzn2+anCktpYkBCLPW8rK9y9cwcnn7lnR+LTfZLCmd3 43jOyPVEi9z5dqlmESVN9qDGApwt1Tlgx/rptIamBLHytigpOahyB0m0nvyXqbu0opJp XhRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070723; x=1735675523; 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=+v7eNfvrqQSZE5BwDanDqUsLKy4GSW+67YoWGKlQXJ4=; b=Cpcr5ctZGdZ7bPO8BrYQFHIUQwmJ34uwocNdFSX/ndPafC1903qnEjK3JHC2p47bEE C+Yzmu2V4DteAedBRZDkiujXb3t2GH2C+HPFeimNX9SeaCUWUcYx/4CCMn7c5DqEL6cc 4coFO/21xpjSzW2di1winO3Fazmaan7BU6sSyFFtk+XtvgSFzYXwJksZSoG4OUkcuf5f gZHk3SrtJrBiW20SPD0MRovMtpuwIlWLC5qvdJ8bT7Dm8tLJ4YyyP6Jh3N7arFavz28k yofQzx8R4n1XIPDPkykl2fZA2JtkaD2G0uGKB8PLrzRR1n9BjslSBOTWRSKWycAqcPD/ nXOQ== X-Gm-Message-State: AOJu0YztmSeIJL9dre06sLOfFURr+gl/7lxFAR1i4cQ+O6dJnYQRBiPn 1XHUitIfECWfg+pnbhgjv5KWzJ+DXxW605deLy8RhjiC/8Q4hbyVn3KzWoZjlVvcbgrSQyId3xz XF2w= X-Gm-Gg: ASbGncsh/8UM35HlcCN31bGB55WAdnUg5QVa0ykCFiHP0cOnKK2+3ivYE1DhLs/i36F +x3tBwPz1N2kUwDSrmD/LDKi3IB3k70M63rcC3BrQskOMryILwDnLEYqqt2FrnGuFSoZ98+sifW j80qr93cXbCBRrSxTYl6L34E2lV5Z2FgWDKELl9oGdj90brHpRq99zvLjr2H0SNF3GqvCDdPWkm Is62jMG7nblPbP6vF/q73lWjvfinrsK8dH0rtOzE7ukq3nzjMioZZvYiI9Tyfp6upPR36ANIejd JILZaGT1903nrBABNYwDoLOf9g== X-Google-Smtp-Source: AGHT+IE5br+fXAv0BqRRd2AqdrFaSlgjeIaohIQa8ZYlAySt/S5VFuX8jjSY62EVYOYlGWyJE7NRXw== X-Received: by 2002:a05:6a20:841d:b0:1e1:b19a:fb58 with SMTP id adf61e73a8af0-1e5e0480dc7mr31260952637.13.1735070723567; Tue, 24 Dec 2024 12:05:23 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Paolo Bonzini Subject: [PULL 01/72] tests/tcg: Do not use inttypes.h in multiarch/system/memory.c Date: Tue, 24 Dec 2024 12:04:10 -0800 Message-ID: <20241224200521.310066-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich make check-tcg fails on Fedora with the following error message: alpha-linux-gnu-gcc [...] qemu/tests/tcg/multiarch/system/memory.c -o memory [...] qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal error: inttypes.h: No such file or directory 17 | #include | ^~~~~~~~~~~~ compilation terminated. The reason is that Fedora has cross-compilers, but no cross-glibc headers. Fix by hardcoding the format specifiers and dropping the include. An alternative fix would be to introduce a configure check for inttypes.h. But this would make it impossible to use Fedora cross-compilers for softmmu tests, which used to work so far. Fixes: ecbcc9ead2f8 ("tests/tcg: add a system test to check memory instrumentation") Signed-off-by: Ilya Leoshkevich Reviewed-by: Paolo Bonzini Message-ID: <20241010085906.226249-1-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- tests/tcg/multiarch/system/memory.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c index 65a6038a24..7508f6b916 100644 --- a/tests/tcg/multiarch/system/memory.c +++ b/tests/tcg/multiarch/system/memory.c @@ -14,7 +14,6 @@ #include #include -#include #include #ifndef CHECK_UNALIGNED @@ -511,8 +510,8 @@ int main(void) int i; bool ok = true; - ml_printf("Test data start: 0x%"PRIxPTR"\n", &test_data[0]); - ml_printf("Test data end: 0x%"PRIxPTR"\n", &test_data[TEST_SIZE]); + ml_printf("Test data start: 0x%lx\n", (unsigned long)&test_data[0]); + ml_printf("Test data end: 0x%lx\n", (unsigned long)&test_data[TEST_SIZE]); /* Run through the unsigned tests first */ for (i = 0; i < ARRAY_SIZE(init_ufns) && ok; i++) { @@ -529,8 +528,8 @@ int main(void) ok = do_signed_reads(true); } - ml_printf("Test data read: %"PRId32"\n", test_read_count); - ml_printf("Test data write: %"PRId32"\n", test_write_count); + ml_printf("Test data read: %lu\n", (unsigned long)test_read_count); + ml_printf("Test data write: %lu\n", (unsigned long)test_write_count); ml_printf("Test complete: %s\n", ok ? "PASSED" : "FAILED"); return ok ? 0 : -1; } From patchwork Tue Dec 24 20:04:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1288CE77188 for ; Tue, 24 Dec 2024 20:10:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9t-0002li-Bh; Tue, 24 Dec 2024 15:05:37 -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 1tQB9j-0002jU-Ir for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:30 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9h-0002Us-Of for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:27 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21680814d42so52211635ad.2 for ; Tue, 24 Dec 2024 12:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070724; x=1735675524; 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=ZG6ae1a+VQYDF+HP8pwyU2WyU4xA7uudCLK9pyvDcw4=; b=YP/8EBKQCBeA+I5TNXMTHmBe8XG4ifwGnXK3FuD5QELLegUs0iC/r8911ZJVIQ/yWp rO9LNdSuKLNVpKt16KxOLeYV5ht4Wsnh3TpV4auhHwRLE9V3/7PRi+PDllGlnih59dMi 1Sy/VrhK2vUwb4jR8c2/RA+UK20N+pO6BWcVBAe7YcXhDlMdFy/TyyHSbVQDYiyP8Sah lMpQ4i3xMdJ+L6uDQjI4mNMf3fLGgGtZQZ3SxOKkvAPr8sMs3xsnkaIFG77uhh8flpK5 I41mHnqSLLeBU7+OYYKZLbe4dnU3U1a9Kx4GCwoaDJoX8xVG4h3mo1U7x7ApTvU6Mw+/ kkEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070724; x=1735675524; 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=ZG6ae1a+VQYDF+HP8pwyU2WyU4xA7uudCLK9pyvDcw4=; b=iiNq6fyfsnpjgHPSmkAzkP3MHnKEzxTwfLx9gktE11gAj4g6IWHOZpGLCggMySyJB+ Qy32Z8jV/lAsiPwNfkvqmgmfgPydpug66+etxjj8+yehH8gnv78yuc1PDXWwyEnYzAtd 1E/Ul+smEh9ed7T/qHoRw5Zl5fQlpNk3i2DJAy3gfLqgGygSX57FEcrrr6MmrJqL4XE6 Q/R4ZIWEO+d6HDCoPrhCbsww6+qRvOTUM5mNRDyzp45DzXJUIabpilp/BNtW+q7hlr4U v3bZg7Qn9PB1b0pT0fJxaufXVQS7AzXYxCMosUKNCBqUafD0nX0ZSMRcprq3lu89ibd+ sx+g== X-Gm-Message-State: AOJu0YzSqtwRyUKPcXPqUu5dhOsoMOdxMY5P9dFkVyB0HMYwLWlg53sR Ki1e2Dbv6pFU/2W3dzolu7CYWORAGcK4FtLUeSJb9QCrVvamoJjzMPch14u8EVei78annICC5xJ 759k= X-Gm-Gg: ASbGncvUdkWr0xkH3K3W8Duetq602cKkm59hDgzPhKnjFJ/al8gsXx1b5EjoZfBfPwn U6O9cEZsjFDb8gDre6kQ3QXvAoau+U85VU22taJozRxvCpOBtRG3SmmCwZRxBwutVLYX78SW/MH KTDUslClD/v0utfEL7K0UVCtQkEAzfNV6WSjS/OyaBQIaX4tpWYprRRZdTSDYGQmthZYEGrena+ WRXIdyyc8gGRggA3VrlKS0o+rOPXJfI5bHim17/e6srle7OV5AU0LgngSaDMOLWUE7pYsLsijc7 mljd73JeW10UF+riw6dq490Vjg== X-Google-Smtp-Source: AGHT+IFdNm+EyAWGLjV3/jJAWhfmIhhQ8Z+LaOj59eyJnoiNa9sy9eSt2bkPNUgu7rxrcl0m+D9BYQ== X-Received: by 2002:a05:6a00:1942:b0:725:cfa3:bc6b with SMTP id d2e1a72fcca58-72abde404b0mr26512426b3a.3.1735070724395; Tue, 24 Dec 2024 12:05:24 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 02/72] plugins: optimize cpu_index code generation Date: Tue, 24 Dec 2024 12:04:11 -0800 Message-ID: <20241224200521.310066-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Pierrick Bouvier When running with a single vcpu, we can return a constant instead of a load when accessing cpu_index. A side effect is that all tcg operations using it are optimized, most notably scoreboard access. When running a simple loop in user-mode, the speedup is around 20%. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Message-ID: <20241128213843.1023080-1-pierrick.bouvier@linaro.org> --- accel/tcg/plugin-gen.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 1ef075552c..7e5f040bf7 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -102,6 +102,15 @@ static void gen_disable_mem_helper(void) static TCGv_i32 gen_cpu_index(void) { + /* + * Optimize when we run with a single vcpu. All values using cpu_index, + * including scoreboard index, will be optimized out. + * User-mode calls tb_flush when setting this flag. In system-mode, all + * vcpus are created before generating code. + */ + if (!tcg_cflags_has(current_cpu, CF_PARALLEL)) { + return tcg_constant_i32(current_cpu->cpu_index); + } TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); tcg_gen_ld_i32(cpu_index, tcg_env, -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); From patchwork Tue Dec 24 20:04:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA2D6E7718D for ; Tue, 24 Dec 2024 20:06:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBA1-0002oR-5z; Tue, 24 Dec 2024 15:05:46 -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 1tQB9k-0002jW-66 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:30 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9i-0002Vj-J5 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:27 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-21644e6140cso59036495ad.1 for ; Tue, 24 Dec 2024 12:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070725; x=1735675525; 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=i8y2SP5gsVRd2DDyIzSjHzTbblUtHqyMo6MFtQTYJr0=; b=W4nI2Ds2quteX6Et2TlbzRKDIrAwJuQSnBaXNatDUIhhqPQoFfDusMKGmZWGQTs4L+ mtEZ1hyUvjQRxf5fOrDPFIz9tqZE4nJBLHs07cHJsEvl0+A68+ldn1NODh/gcg/Drryl ThpJI5d02hOg/2HnkGT1ZzGSycki8sVu3NyUsDIfWuUXKk9+bvmBWd2oQAo6s53pbtXP ha2S7IdAUnzXfnV+uEiahuvlwYCOdbDiKF9A5aK4bW1KhBtfpOnBQ2K795ihcNyXlLC/ 3RAf2loDnCUXCkmTAJbpjSQqpCFEKwrS7d+XZnXHAnUY1aVDzjbzMd3lRXnDkPrA3nm6 0paQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070725; x=1735675525; 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=i8y2SP5gsVRd2DDyIzSjHzTbblUtHqyMo6MFtQTYJr0=; b=HNBpa8q0zFQs0uIrR1aIO17hYpKefD3y3v2v48W4VkLvioh3ZXE37tMx6SHU0pKD9Q +naSc3bW8qHdV9HXqBstqFLs+qAi8z0g36+fTxUoA36QhCMs0mzKPdtZjtELk+7Tvhs3 FQj1TknknPtQh2XHmbO3aGG/0Oa9znGK+dXT33PHJy0hqRydGIeB9hU57gQW6SC60Ru3 9xspiP2xZl9j5Mh1epTGaU5Q6FBgIv8ckQgmSXmvU6BbNXldFfVyoePp8K+Nn19oTxKO cZ+D92ehnqopy9lni+17v+huzoYPE55VDPbGoSH3/mfOl+42+cMwEy6i9ZIrVuwpHFFy 9WmA== X-Gm-Message-State: AOJu0YzTTTqyuCG6nb1xu2Z0uCdcGYbIvnlyJkd0VipBUQyTzanr+YHU 3h0BqE4hCTsR9ZVF0ffbElJ2oF8uQqb5RXBtIow2YS2jcbep/rU7X4pN4P52FKlrP2DoIIPUxD5 wDkI= X-Gm-Gg: ASbGnctnlPvGmMOYxJWhc2LI1fOtyz6gIJrdn5vzx0K9i6bwY1j2hGQ4/XRqXjb3jn4 n4uhdbpnTwlHbq5vNY2aKQ+QQtWXPa75lJTr9LnmBTLtbQiFsIhv6gof1tN6cNXQbzbcEsaKt5x SLHPSERWeM7h47XzWKi33YZhGU1x5Qzi0QmTY+Ds0vpqicvSf8j0VWYwScy37cXGQGxklQ64OEd sMQ6gmRVuE+c5u4YuEvG7TfgkjgKZgaO/bNTdtuCw29FEAyeP0/rVvGaN/sYYd7ddeGbVEmBiPy yYLsoemopPKdmp3GaaIF0dAFtA== X-Google-Smtp-Source: AGHT+IEJhtGzb5grS1teMnZupHJGmViLG1uhDx4sk3FeLbNd2Bjm/NuRpr0ruv4CcQ7iWbnrcskb+Q== X-Received: by 2002:a05:6a00:3cc2:b0:71e:4cff:2654 with SMTP id d2e1a72fcca58-72abdd6eb8cmr21763038b3a.6.1735070725198; Tue, 24 Dec 2024 12:05:25 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 03/72] tcg/optimize: Split out finish_bb, finish_ebb Date: Tue, 24 Dec 2024 12:04:12 -0800 Message-ID: <20241224200521.310066-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Call them directly from the opcode switch statement in tcg_optimize, rather than in finish_folding based on opcode flags. Adjust folding of conditional branches to match. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index e9ef16b3c6..453e8c43bd 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -964,24 +964,25 @@ static void copy_propagate(OptContext *ctx, TCGOp *op, } } +static void finish_bb(OptContext *ctx) +{ + /* We only optimize memory barriers across basic blocks. */ + ctx->prev_mb = NULL; +} + +static void finish_ebb(OptContext *ctx) +{ + finish_bb(ctx); + /* We only optimize across extended basic blocks. */ + memset(&ctx->temps_used, 0, sizeof(ctx->temps_used)); + remove_mem_copy_all(ctx); +} + static void finish_folding(OptContext *ctx, TCGOp *op) { const TCGOpDef *def = &tcg_op_defs[op->opc]; int i, nb_oargs; - /* - * We only optimize extended basic blocks. If the opcode ends a BB - * and is not a conditional branch, reset all temp data. - */ - if (def->flags & TCG_OPF_BB_END) { - ctx->prev_mb = NULL; - if (!(def->flags & TCG_OPF_COND_BRANCH)) { - memset(&ctx->temps_used, 0, sizeof(ctx->temps_used)); - remove_mem_copy_all(ctx); - } - return; - } - nb_oargs = def->nb_oargs; for (i = 0; i < nb_oargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); @@ -1351,8 +1352,11 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op) if (i > 0) { op->opc = INDEX_op_br; op->args[0] = op->args[3]; + finish_ebb(ctx); + } else { + finish_bb(ctx); } - return false; + return true; } static bool fold_brcond2(OptContext *ctx, TCGOp *op) @@ -1443,9 +1447,12 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) } op->opc = INDEX_op_br; op->args[0] = label; - break; + finish_ebb(ctx); + return true; } - return false; + + finish_bb(ctx); + return true; } static bool fold_bswap(OptContext *ctx, TCGOp *op) @@ -3037,6 +3044,14 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64_VEC(xor): done = fold_xor(&ctx, op); break; + case INDEX_op_set_label: + case INDEX_op_br: + case INDEX_op_exit_tb: + case INDEX_op_goto_tb: + case INDEX_op_goto_ptr: + finish_ebb(&ctx); + done = true; + break; default: break; } From patchwork Tue Dec 24 20:04:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD18CE77188 for ; Tue, 24 Dec 2024 20:06:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9u-0002ly-Vq; Tue, 24 Dec 2024 15:05:39 -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 1tQB9l-0002jX-9j for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:30 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9j-0002Ws-MR for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:29 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2166f1e589cso67033785ad.3 for ; Tue, 24 Dec 2024 12:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070726; x=1735675526; 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=iOzpxqZ9VNfy3l9f3NLQHzVfPYu5zW7VkQL9KwFwxnA=; b=xcLWc0LJluNu9CiKwHB1b/v9WGr0iy/kgAYBBZ+mTVb6eIkwlSIpvg/ATl8PDZ3aoL OSP4HLFLoJ/pmYZHtDCQiaCYxJ5gVTrbIJGOVSM8akb0oIkNALvNevi4ljpkYU6amBHm i4YynXDzU0joKD+Onsi7bcjcXzlOAjHmaMgVTL4+Led/2DKhXOB/3eTzU5PJqZpKL+Cv SBYfKnx6Jx161YUUl0qMZgRbP5lreHVeqt5MmbawIsEIen5q9GauClEGagOkf1SkKmHw xYMP/ZLHhgLd4xvKRLfl3N2SC0O6KmL1U6VfjndhAsCTU6ie/C/KsAGd7lMHokn4BCSx M+2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070726; x=1735675526; 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=iOzpxqZ9VNfy3l9f3NLQHzVfPYu5zW7VkQL9KwFwxnA=; b=SNfLUhF5nN2rSGa9SwHrZVfMmXNNVaV3EtNyn6lnbBJ4HL+SJ7qZvoPToatoJasT9Z z8YHkzQt3vpkU8KyXkYaM+16fmT++H07Jy4GLV4GQDFTfvQ+yOza4AFS1adP2sOtWG7K aIbor6cty7yL0V4p85gtECMRD/6h/sObLr1z60llmzwj0vaoIvQ3ufrYD3z/GBpC66v0 gkRmFPYew52k/Kj0x8GrADWK7Rl8KiDpuLZ2XZc6IU6H4MyKFj7F4aMvVg/rXlRLAYdp nI96LhzLRsHpLnY1kcgMr8G4KKMf0vFr6i7fDgI9laKfXoyOz+WMVWxryiYCdVOepg/X /hoQ== X-Gm-Message-State: AOJu0YyPDLpwtdlqvhs2B0tEZ6hYcslk/jMrGnAqMpgp2amfYcqxgH8X hD/TIroyi1+40GQmkgGoZM3+VmMc9HiBkhKvdOwVdQkS18hhyST2CYKQiO0/D9rDP9CjVV5xVY0 af54= X-Gm-Gg: ASbGncv7psoRQMr7filob/BdTdEXhOJ6DN/kNSEUAl+Xu18RyYI8fBPgxW1W++ISlcG WD3FdDOXBFVrJu+y21dm0S+Rudm1A2Sy8gB5guoKBbcxq+8m4ZFj9Z30kcXebxBUsIzyRS2Pq4U 7y01TWK2s2AFICSOd9vnN3ADcX+cLgyMA+9fJ9l3rcE8qsLVgw4Xmu5JzY8jCzD1gW6qV7a61QB cEBQ6OHx8ivna6tWac7zEa8d1sTclXtZuI8diqG5JzCqtvshDWlMRHn/Lj7gjsGGs6nMNTurm0M KLg8NnhJXO+neIJgy5t2Az4fpw== X-Google-Smtp-Source: AGHT+IFX+rO/BfMWuku7Q9xzFRU3p3Nn4e8mGAzI0HIjaO78nybOXFotFdlMEt5qPX4z7c+1UkiWbA== X-Received: by 2002:a05:6a21:3103:b0:1e1:a932:4a40 with SMTP id adf61e73a8af0-1e5e043f517mr25728596637.4.1735070726119; Tue, 24 Dec 2024 12:05:26 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 04/72] tcg/optimize: Split out fold_affected_mask Date: Tue, 24 Dec 2024 12:04:13 -0800 Message-ID: <20241224200521.310066-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There are only a few logical operations which can compute an "affected" mask. Split out handling of this optimization to a separate function, only to be called when applicable. Remove the a_mask field from OptContext, as the mask is no longer stored anywhere. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 453e8c43bd..6757fe0036 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -64,7 +64,6 @@ typedef struct OptContext { QSIMPLEQ_HEAD(, MemCopyInfo) mem_free; /* In flight values from optimization. */ - uint64_t a_mask; /* mask bit is 0 iff value identical to first input */ uint64_t z_mask; /* mask bit is 0 iff value bit is 0 */ uint64_t s_mask; /* mask of clrsb(value) bits */ TCGType type; @@ -1047,7 +1046,6 @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op) static bool fold_masks(OptContext *ctx, TCGOp *op) { - uint64_t a_mask = ctx->a_mask; uint64_t z_mask = ctx->z_mask; uint64_t s_mask = ctx->s_mask; @@ -1059,7 +1057,6 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) * type changing opcodes. */ if (ctx->type == TCG_TYPE_I32) { - a_mask = (int32_t)a_mask; z_mask = (int32_t)z_mask; s_mask |= MAKE_64BIT_MASK(32, 32); ctx->z_mask = z_mask; @@ -1069,6 +1066,19 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) if (z_mask == 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], 0); } + return false; +} + +/* + * An "affected" mask bit is 0 if and only if the result is identical + * to the first input. Thus if the entire mask is 0, the operation + * is equivalent to a copy. + */ +static bool fold_affected_mask(OptContext *ctx, TCGOp *op, uint64_t a_mask) +{ + if (ctx->type == TCG_TYPE_I32) { + a_mask = (uint32_t)a_mask; + } if (a_mask == 0) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); } @@ -1305,8 +1315,9 @@ static bool fold_and(OptContext *ctx, TCGOp *op) * Known-zeros does not imply known-ones. Therefore unless * arg2 is constant, we can't infer affected bits from it. */ - if (arg_is_const(op->args[2])) { - ctx->a_mask = z1 & ~z2; + if (arg_is_const(op->args[2]) && + fold_affected_mask(ctx, op, z1 & ~z2)) { + return true; } return fold_masks(ctx, op); @@ -1331,7 +1342,9 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) */ if (arg_is_const(op->args[2])) { uint64_t z2 = ~arg_info(op->args[2])->z_mask; - ctx->a_mask = z1 & ~z2; + if (fold_affected_mask(ctx, op, z1 & ~z2)) { + return true; + } z1 &= z2; } ctx->z_mask = z1; @@ -1709,8 +1722,8 @@ static bool fold_extract(OptContext *ctx, TCGOp *op) z_mask_old = arg_info(op->args[1])->z_mask; z_mask = extract64(z_mask_old, pos, len); - if (pos == 0) { - ctx->a_mask = z_mask_old ^ z_mask; + if (pos == 0 && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) { + return true; } ctx->z_mask = z_mask; ctx->s_mask = smask_from_zmask(z_mask); @@ -1777,8 +1790,8 @@ static bool fold_exts(OptContext *ctx, TCGOp *op) ctx->z_mask = z_mask; ctx->s_mask = s_mask; - if (!type_change) { - ctx->a_mask = s_mask & ~s_mask_old; + if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { + return true; } return fold_masks(ctx, op); @@ -1819,8 +1832,8 @@ static bool fold_extu(OptContext *ctx, TCGOp *op) ctx->z_mask = z_mask; ctx->s_mask = smask_from_zmask(z_mask); - if (!type_change) { - ctx->a_mask = z_mask_old ^ z_mask; + if (!type_change && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) { + return true; } return fold_masks(ctx, op); } @@ -2482,8 +2495,8 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op) s_mask |= MAKE_64BIT_MASK(len, 64 - len); ctx->s_mask = s_mask; - if (pos == 0) { - ctx->a_mask = s_mask & ~s_mask_old; + if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { + return true; } return fold_masks(ctx, op); @@ -2843,7 +2856,6 @@ void tcg_optimize(TCGContext *s) } /* Assume all bits affected, no bits known zero, no sign reps. */ - ctx.a_mask = -1; ctx.z_mask = -1; ctx.s_mask = 0; From patchwork Tue Dec 24 20:04:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99AD4E77188 for ; Tue, 24 Dec 2024 20:06:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9w-0002mj-T3; Tue, 24 Dec 2024 15:05:40 -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 1tQB9l-0002jY-Ey for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:30 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9k-0002X3-1p for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:29 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2162c0f6a39so64868855ad.0 for ; Tue, 24 Dec 2024 12:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070727; x=1735675527; 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=kwAmrbK+z6InFUYOYJQouqu9jlEe2zkE3MrW95sabRA=; b=hptUS2Qc/0PzPXBWt5iKl0AuHcyGIEIHu5iwdrsBDtFbZ+QdI17AJc2Ng3BTTZicLG sPW1v6qbPRtWPW0NkBdxU4h5P/cPA/49xDZoX52xYxz3Qi+Yg8ve0ejz+0Hx+etUTTBP WCkdlLbUN2mQuSJJzmNrhk4xT59qAa5uPxxrfhh5SVezQn6nifCfZ1WSKBTfiBcAU+5O whxC0wZi1LTGUKqKMeB08UDUJsREP0wKTIsLlqRCZPnOAVtz5O0uCenS8KgnDudSdsGy DT3ykdXyOU/7gW4ErlWh/lzMRrVMn+ZfenMYMjpYDyUDrSqDTM+p1P/rI91HqvU9JVpS QReg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070727; x=1735675527; 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=kwAmrbK+z6InFUYOYJQouqu9jlEe2zkE3MrW95sabRA=; b=qpMVj8oiDI/OoWStCDjlpQB6kLsItzQ5cAN6/RqXuHYwIn5Rm5sh3sZybamuCeK+AF 0qoLJ7hqUU2uFRUkEwgl9CSy2f1esccHg4aAv8ZumKHZPJq7cclWCssuYhmslWyO56Xx eesOaAxb7TK+PODsiDhfvK4p+NukTY3IFfdMC3EMF44AtPm8vDgN091HI4lBf4tbo4V5 eYO0lc+oQRtmAB2xh6/d2Ef2TNuTbrXi4TfcyXn1eg+9VfP3e/KtDM+lObuIN8bam/vs xNaaNPmmnWlq/VHVtEyeHPELKpjuXx6hVC4BW/eQxN2/gshBwC0dCNBZ2G5nr+b7w59R CNNg== X-Gm-Message-State: AOJu0YyAAbQHa0AjoZEXLFejItzTjkNGYtCV/pnx8hw01kl3PZao6N43 3IN1em8p8eJ51gwaxNiWhxlXwQ/HW6CIP9K0X9lRJOofa4aIzjTlzFw0dpzvv4Dq6Sn6+0ueDuk SNfY= X-Gm-Gg: ASbGncuUYC2FfbM2NRE+Er3sNTbaVtRP7o83W06JpMnu+Eh5fBY9Pviv9c9GKo1ky4+ ak3/8E88F2JBEIFWD8u3XGA2Bs79nawKgn6a/F+Ofw3exSz0FQYZPx2L9PvF7ejNGATiGoRHMWz x7L33ElOTw9Optqk1Va6H4odC99LXKydItgclH733l8U7Jna+pB7gYj+9MNoqtfn/OfJSHHp0Kk KJL1J0w6vpdXMCi1McBUNkdSKWU57d+rh0ctWbCVnwzlTO60wCLUMUfW/GQsvmhN80KHq6S9Jea gHbJ4GrYcXoLDqN+TYXN3VZMVA== X-Google-Smtp-Source: AGHT+IFCi+I/DGuultM+PzXQifT0v2IbJhVOIiEoqreS4k/Vpz0TfuHlStaFDtW3zlQKnwy8l1aNxQ== X-Received: by 2002:a05:6a00:69ad:b0:725:f1e9:5334 with SMTP id d2e1a72fcca58-72aa9ade355mr28645965b3a.8.1735070726851; Tue, 24 Dec 2024 12:05:26 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 05/72] tcg/optimize: Copy mask writeback to fold_masks Date: Tue, 24 Dec 2024 12:04:14 -0800 Message-ID: <20241224200521.310066-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use of fold_masks should be restricted to those opcodes that can reliably make use of it -- those with a single output, and from higher-level folders that set up the masks. Prepare for conversion of each folder in turn. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 6757fe0036..2aa57afd64 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1048,6 +1048,12 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) { uint64_t z_mask = ctx->z_mask; uint64_t s_mask = ctx->s_mask; + const TCGOpDef *def = &tcg_op_defs[op->opc]; + TCGTemp *ts; + TempOptInfo *ti; + + /* Only single-output opcodes are supported here. */ + tcg_debug_assert(def->nb_oargs == 1); /* * 32-bit ops generate 32-bit results, which for the purpose of @@ -1059,14 +1065,19 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) if (ctx->type == TCG_TYPE_I32) { z_mask = (int32_t)z_mask; s_mask |= MAKE_64BIT_MASK(32, 32); - ctx->z_mask = z_mask; - ctx->s_mask = s_mask; } if (z_mask == 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], 0); } - return false; + + ts = arg_temp(op->args[0]); + reset_ts(ctx, ts); + + ti = ts_info(ts); + ti->z_mask = z_mask; + ti->s_mask = s_mask; + return true; } /* From patchwork Tue Dec 24 20:04:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86106E7718E for ; Tue, 24 Dec 2024 20:06:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9w-0002mk-Tn; Tue, 24 Dec 2024 15:05:41 -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 1tQB9m-0002je-JQ for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:30 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9l-0002XI-4g for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:30 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-216401de828so54800755ad.3 for ; Tue, 24 Dec 2024 12:05:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070728; x=1735675528; 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=6O0RsWWKqdEinIh2H96IW4WRMj9sIUVKDwhRVVNpMf0=; b=R0LncO7iqnfvdWdHnmBW90w4sao/4HqmR/WnRXAW4PGPLyQ1dr+W1Xnt5zF0/Nf0xX T0tOXsDl64IOo8Y8fyVrLpkHcjE9UjK8J29xgu0HMCsMxqYv3nrXDGkZ16U0Ef1Le//3 lL/ArsTBsG+s4ysdLWO7tet4ZzRtre+2Z69zkYUCjgtnSp29iWF3quriHY8B/XpZhefT Z7MicNU2x4sHBFRfjl1YZ2y/qxZVMvgJ3Var9E5oXld+uqO+a+SSNU7y284pc04HWKrY MGhf3b4sPwXr/MVj7uMwRRX3h7G80dagX4n0jfIu2AQbSY1AyFDmepVJOL0mL70LfYvC 7fVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070728; x=1735675528; 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=6O0RsWWKqdEinIh2H96IW4WRMj9sIUVKDwhRVVNpMf0=; b=gzbhG9apv8e/vk13WYpw/7NfuXwKsPNEVCLbgju14sS0BTSTe1Vc0iOKHk0aAOMMBZ uFqr3hEOaJtpMkHHKz6i55aNcOhVz/1qjsohwJQo7tIoMXPzoAOQdAe4kxzOx+lX1sSt nDGj0NM0yUjXd8b2z4io8LCIfI1hq9t3XaypDsk487+YqGmERktP04AbjoEuIpg13wv0 B6qoLiPWvjMfN6K9qlgs55NoC5vqTQzz3n3TYWtdRH+7jXHzVsRPbB4APBaPw5zupCrM 1l3ndRG4ezUBvvax2jSpF7f5eTYGj0WRuDC9wSBCQgGI0qqCu2k91yM2jAvKtqEyn72Y MugQ== X-Gm-Message-State: AOJu0YwNob8apu0bZuJdiKukUoHLngCF3YgOMLUQxXtJW+ddpuVKYZpT vC8wsGczQfdgbwap09L95M2rPjTivQEEHTSNg/B36lYOUIwuAW02mmoKOSZdHiPcn3kRr78G0rJ mMsA= X-Gm-Gg: ASbGncvBBrqqrNEGOw9cML0fR8LhyOC3td7d6YERT3MuNomY6zD4iNko29apWCzv2/X NZSj7QCI0J0+1jMlSWL+TYdasfURNnVD5GGATKjnsi/mnnITCxZL0xd/amo7CL2TmSPAmqhdaoa y4RL9qf9uGV+07ivGqThpx/LH5Os4bJM5c12CUr4yXVWNt0dO2X3Une4Batp4FVMW8W6Zm1uUcU C6X/u+FqEo2etk6o7xBWSf9HOgglwT3KUfRCgIKdTA84bDs1phhxYiLZI2CtWWYYFy4otsnkV+u SgAAoQ3tMMOBbgrsPbXkOxDOKw== X-Google-Smtp-Source: AGHT+IGjqRyBI3PNaSVIgxXcJVAjXo4Bl73aj9e63UokeBhRzupOOOyhMy4X/kFHj62fXuIxXpQV+g== X-Received: by 2002:a05:6a00:44c4:b0:725:e405:6df7 with SMTP id d2e1a72fcca58-72abdd7f683mr26519750b3a.10.1735070727737; Tue, 24 Dec 2024 12:05:27 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 06/72] tcg/optimize: Split out fold_masks_zs Date: Tue, 24 Dec 2024 12:04:15 -0800 Message-ID: <20241224200521.310066-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a routine to which masks can be passed directly, rather than storing them into OptContext. To be used in upcoming patches. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 2aa57afd64..d70127b88d 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1044,10 +1044,14 @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op) return fold_const2(ctx, op); } -static bool fold_masks(OptContext *ctx, TCGOp *op) +/* + * Record "zero" and "sign" masks for the single output of @op. + * See TempOptInfo definition of z_mask and s_mask. + * If z_mask allows, fold the output to constant zero. + */ +static bool fold_masks_zs(OptContext *ctx, TCGOp *op, + uint64_t z_mask, uint64_t s_mask) { - uint64_t z_mask = ctx->z_mask; - uint64_t s_mask = ctx->s_mask; const TCGOpDef *def = &tcg_op_defs[op->opc]; TCGTemp *ts; TempOptInfo *ti; @@ -1080,6 +1084,11 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) return true; } +static bool fold_masks(OptContext *ctx, TCGOp *op) +{ + return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask); +} + /* * An "affected" mask bit is 0 if and only if the result is identical * to the first input. Thus if the entire mask is 0, the operation From patchwork Tue Dec 24 20:04:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68BEAE77188 for ; Tue, 24 Dec 2024 20:06:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9u-0002lw-Uk; Tue, 24 Dec 2024 15:05:38 -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 1tQB9n-0002kT-Tj for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:32 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9m-0002XW-Ax for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:31 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-21669fd5c7cso57784075ad.3 for ; Tue, 24 Dec 2024 12:05:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070729; x=1735675529; 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=0XbbAA6tPaSy58TXvgA24Kz1zz5lDy83D/6o1p8rm3g=; b=iyPogcdMBkfObjKqSzGho6xFZuGnanmIkOd2YZXZ0gJZHwWS+lSiMFSxYTOb5rZdM1 P1tOLUimDiUQ/6YyWo2TnNY9ZPkjXswc8V67XjiVX9ogroX3AACuKGGGmW/g5uqLFuHk HgX/vEm8I2UIog0bbYbWlT/DGDyXHBY/yZ8qVFpPp1RI8LSOsIBW814defj2+lyZYulV 7zqTh+EzZ2SB8015c1bQSsx8hjSFxc0BotZNv7AP+H9gr2i/KaHSwtPVdHtkrQIIOhuW 9I9B6rqzhowMrBLR3IcqYJcesiu8acW25w5eh/HjqpL3Uqjhu3NeegJ8ofsFyfuXEMnT 43fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070729; x=1735675529; 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=0XbbAA6tPaSy58TXvgA24Kz1zz5lDy83D/6o1p8rm3g=; b=VX4FyZ73IOgMsSIja3MZUHhU668C7L2Q6dhRoiM0DV+P3lWqFMTFLw2YPxSbHBq1uo UVAmMLnwYtG9F4gZjkprZPWwalmo2YJa3ash8d5ZQLBaC+cpdn9hGvh2Nzei1pQaT4io EfSGdpxcTwLJpUlxiRI7gi1amJwx1O13PHqG2reLX4zVxS9A7WOOUWWgFiAzt+TAoYnG +hIhMXOWBPCQsFs8tn+dGgX+iCG/rdvS0X1EWRJMQDZsACGPcNmZtWZmgUwVV2aIvxhh riAsoYYvZbgk7TlIfBO4h6xb6SS3DF8YHIm84TiRO3wjcjMUB7mJ2kNFCca4PgG+9yAh 2bog== X-Gm-Message-State: AOJu0YwFKO2z/OsA6VhvH6+ad6eFezQ0AB1mhXb/2Z7DmjUZxTMpwYY5 ODM/+74j/RM2u0/xYod/0ZXQErS1NfL8TVQbZfh/lACx/4EZHW3Y5l4SsLfufzLXqzJV4WrAj5j OMsA= X-Gm-Gg: ASbGncveBmkC3O8hCV3NLKI502LYTX3Hzef29lKTSG1sd8+hdig/CphoJcmd5X0i5Bv k8ElVgOxBg4LscIVh0AkLV/cQ8NjqOgiwGE1i9Wobvp7/S2tkjO9S5eXNZc8os1lS/rEXaTZghB LDzzpDP1DXhUgfdZN4lCIgEbiUYQZ8qePCvNWfecbcymOYq+mrUeZGv74a40MINThVF5mAwEown hbKaVCpuWP8HtXYpgUIG9Kd9fBqQbEkfatXazKni+dtzRaPILQNBSYVaIOYvxQR4Hcp2anDptRK O9Wtl2AA+Cm5XAGnhinEu9LKVA== X-Google-Smtp-Source: AGHT+IFBmVM1jFTBKb6tzrSei8LhDAUidJTRfiCAWRicFaZfa0E9JSf1qCKcxGtpjxePO7xJZPSbJg== X-Received: by 2002:a05:6a00:889:b0:71d:eb7d:20d5 with SMTP id d2e1a72fcca58-72abdd7b8fdmr31105365b3a.8.1735070728843; Tue, 24 Dec 2024 12:05:28 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 07/72] tcg/optimize: Augment s_mask from z_mask in fold_masks_zs Date: Tue, 24 Dec 2024 12:04:16 -0800 Message-ID: <20241224200521.310066-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Consider the passed s_mask to be a minimum deduced from either existing s_mask or from a sign-extension operation. We may be able to deduce more from the set of known zeros. Remove identical logic from several opcode folders. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index d70127b88d..d8f6542c4f 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1048,6 +1048,7 @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op) * Record "zero" and "sign" masks for the single output of @op. * See TempOptInfo definition of z_mask and s_mask. * If z_mask allows, fold the output to constant zero. + * The passed s_mask may be augmented by z_mask. */ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, uint64_t z_mask, uint64_t s_mask) @@ -1080,7 +1081,7 @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, ti = ts_info(ts); ti->z_mask = z_mask; - ti->s_mask = s_mask; + ti->s_mask = s_mask | smask_from_zmask(z_mask); return true; } @@ -1519,8 +1520,8 @@ static bool fold_bswap(OptContext *ctx, TCGOp *op) default: g_assert_not_reached(); } - s_mask = smask_from_zmask(z_mask); + s_mask = 0; switch (op->args[2] & (TCG_BSWAP_OZ | TCG_BSWAP_OS)) { case TCG_BSWAP_OZ: break; @@ -1534,7 +1535,6 @@ static bool fold_bswap(OptContext *ctx, TCGOp *op) default: /* The high bits are undefined: force all bits above the sign to 1. */ z_mask |= sign << 1; - s_mask = 0; break; } ctx->z_mask = z_mask; @@ -1605,7 +1605,6 @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op) g_assert_not_reached(); } ctx->z_mask = arg_info(op->args[2])->z_mask | z_mask; - ctx->s_mask = smask_from_zmask(ctx->z_mask); return false; } @@ -1625,7 +1624,6 @@ static bool fold_ctpop(OptContext *ctx, TCGOp *op) default: g_assert_not_reached(); } - ctx->s_mask = smask_from_zmask(ctx->z_mask); return false; } @@ -1746,7 +1744,6 @@ static bool fold_extract(OptContext *ctx, TCGOp *op) return true; } ctx->z_mask = z_mask; - ctx->s_mask = smask_from_zmask(z_mask); return fold_masks(ctx, op); } @@ -1851,7 +1848,6 @@ static bool fold_extu(OptContext *ctx, TCGOp *op) } ctx->z_mask = z_mask; - ctx->s_mask = smask_from_zmask(z_mask); if (!type_change && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) { return true; } @@ -2116,10 +2112,10 @@ static bool fold_qemu_ld(OptContext *ctx, TCGOp *op) int width = 8 * memop_size(mop); if (width < 64) { - ctx->s_mask = MAKE_64BIT_MASK(width, 64 - width); - if (!(mop & MO_SIGN)) { + if (mop & MO_SIGN) { + ctx->s_mask = MAKE_64BIT_MASK(width, 64 - width); + } else { ctx->z_mask = MAKE_64BIT_MASK(0, width); - ctx->s_mask <<= 1; } } @@ -2354,7 +2350,6 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) fold_setcond_tst_pow2(ctx, op, false); ctx->z_mask = 1; - ctx->s_mask = smask_from_zmask(1); return false; } @@ -2455,7 +2450,6 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) } ctx->z_mask = 1; - ctx->s_mask = smask_from_zmask(1); return false; do_setcond_const: @@ -2649,21 +2643,18 @@ static bool fold_tcg_ld(OptContext *ctx, TCGOp *op) break; CASE_OP_32_64(ld8u): ctx->z_mask = MAKE_64BIT_MASK(0, 8); - ctx->s_mask = MAKE_64BIT_MASK(9, 55); break; CASE_OP_32_64(ld16s): ctx->s_mask = MAKE_64BIT_MASK(16, 48); break; CASE_OP_32_64(ld16u): ctx->z_mask = MAKE_64BIT_MASK(0, 16); - ctx->s_mask = MAKE_64BIT_MASK(17, 47); break; case INDEX_op_ld32s_i64: ctx->s_mask = MAKE_64BIT_MASK(32, 32); break; case INDEX_op_ld32u_i64: ctx->z_mask = MAKE_64BIT_MASK(0, 32); - ctx->s_mask = MAKE_64BIT_MASK(33, 31); break; default: g_assert_not_reached(); From patchwork Tue Dec 24 20:04:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D86C5E7718D for ; Tue, 24 Dec 2024 20:06:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAA-0002qC-Dn; Tue, 24 Dec 2024 15:05:54 -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 1tQB9o-0002kf-Ra for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:34 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9n-0002Xe-4K for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:32 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-21683192bf9so61841305ad.3 for ; Tue, 24 Dec 2024 12:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070730; x=1735675530; 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=UguTmxMFL4TTxOKQ146kQqPat3A///6xR4q4RSBU0vs=; b=ggxvILR3vS8BOiNzHCattKWGCWjrkje5nrcJRRaAiVG+DDOa/UO2s0Ymu5wCamRSJq OM+zbfXeW3AmLFx9O6hsnrrPDvYDIHXM23tllJeN9aiSdlEO9z02Vhs4e1g7VDuw9A7a Bgsx+yK3d0JzuAMqhHx1rgSpKsCECqTAElr++XrsVHton9pNFuwIY/GkswIVylufs1Mh C/LbzPa7cWSY3Y7v5YSXWGuYN/oOYeRwN2eP5D8onnQL+gQmpXo9ED/ZWcykPxx7UeSB kitqNVj30+gnwiILbWOnAehxewPf+5i9obQtdy0ieXEC90/XsEsAGD9f+hZ6TSS2K9sX OLjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070730; x=1735675530; 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=UguTmxMFL4TTxOKQ146kQqPat3A///6xR4q4RSBU0vs=; b=m8ZAEzFdn2PlNsE3CxEMyrrmhqt3xKXK+1YM7tuZU7RmaD2AubymNo+97SntaELiki qG5Ajw+OcmrPmv7k7LDy34CFpDPzK5gGr+hs05yr3m6uqwnJWzAa9FrlfFg5k0lblOsL 5kA2m2KkKkosG4i7U92I0IfzdVnpJtLGi3UAfAILjNmFrT8k7Ud/TPdk7kaDceMYQ+9q BPrb+teVIOlYvvH428odeJVS8ttanILwKkBZRwXzn0mJ/LQQ+C6qqciEAZCMeij33w1e LdhIa5c7FJn5ispOjnd926G+aRtTTOmFLYnRHUEzET1uHGFjUqSBTQK34Xr/ejUZHL2j ojLg== X-Gm-Message-State: AOJu0YzqNGs7/BBTKzEh7YFodQYBKiMR+6Tjgq0KU4JTAehAynHjUvUo BGSQ5WsI2UKVFRabNTBnMIDjYmBUQlfXzQET42gOhoBunKOzX7XMPTFAgl8wCkMnHyZP4Mkicsp z6AI= X-Gm-Gg: ASbGnctN6DdvrJQ6MYogbxIRt/Qn8f87mV9Pr9ibE69361FCLz+SGbjSLRvpq5BKSU4 RvPZ2h0dhRnAD+MO0DMI9qSqPizBa5iPUkVRsZH/bNvHYS067M1AiZnCo6mBkKrO0xUpOojJHAO RwaXPAPNAKGJO9mJqwQlRyMhQ+ZSQWIRDQMDFlx2PdakzDjqqJd8brpEHUdyyiSzkSBpUQUY7+i 0KNWdlGTFhUC9IB3Ze+x3uO/qeKb/j9wvLRCwePZBC9spOMcB8thV1OHQuA8WnKSW577F95mlts 4MSUa2N4pK8e2AQvyW8hz9EBrg== X-Google-Smtp-Source: AGHT+IG0muVRgUItzNqbZ/kO8QX09URxzbxu2YGbkWmT8+jSUsckR8sULBrMQh8g96FB1F531iBfWQ== X-Received: by 2002:a05:6a00:44cb:b0:725:1d37:ebff with SMTP id d2e1a72fcca58-72abe0960c6mr24861733b3a.22.1735070729831; Tue, 24 Dec 2024 12:05:29 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 08/72] tcg/optimize: Change representation of s_mask Date: Tue, 24 Dec 2024 12:04:17 -0800 Message-ID: <20241224200521.310066-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Change the representation from sign bit repetitions to all bits equal to the sign bit, including the sign bit itself. The previous format has a problem in that it is difficult to recreate a valid sign mask after a shift operation: the "repetitions" part of the previous format meant that applying the same shift as for the value lead to an off-by-one value. The new format, including the sign bit itself, means that the sign mask can be manipulated in exactly the same way as the value, canonicalization is easier. Canonicalize the s_mask in fold_masks_zs, rather than requiring callers to do so. Treat 0 as a non-canonical but typeless input for no sign information, which will be reset as appropriate for the data type. We can easily fold in the data from z_mask while canonicalizing. Temporarily disable optimizations using s_mask while each operation is converted to use fold_masks_zs and to the new form. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 64 ++++++++++++-------------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index d8f6542c4f..fbc0dc5588 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -52,7 +52,7 @@ typedef struct TempOptInfo { QSIMPLEQ_HEAD(, MemCopyInfo) mem_copy; uint64_t val; uint64_t z_mask; /* mask bit is 0 if and only if value bit is 0 */ - uint64_t s_mask; /* a left-aligned mask of clrsb(value) bits. */ + uint64_t s_mask; /* mask bit is 1 if value bit matches msb */ } TempOptInfo; typedef struct OptContext { @@ -65,49 +65,10 @@ typedef struct OptContext { /* In flight values from optimization. */ uint64_t z_mask; /* mask bit is 0 iff value bit is 0 */ - uint64_t s_mask; /* mask of clrsb(value) bits */ + uint64_t s_mask; /* mask bit is 1 if value bit matches msb */ TCGType type; } OptContext; -/* Calculate the smask for a specific value. */ -static uint64_t smask_from_value(uint64_t value) -{ - int rep = clrsb64(value); - return ~(~0ull >> rep); -} - -/* - * Calculate the smask for a given set of known-zeros. - * If there are lots of zeros on the left, we can consider the remainder - * an unsigned field, and thus the corresponding signed field is one bit - * larger. - */ -static uint64_t smask_from_zmask(uint64_t zmask) -{ - /* - * Only the 0 bits are significant for zmask, thus the msb itself - * must be zero, else we have no sign information. - */ - int rep = clz64(zmask); - if (rep == 0) { - return 0; - } - rep -= 1; - return ~(~0ull >> rep); -} - -/* - * Recreate a properly left-aligned smask after manipulation. - * Some bit-shuffling, particularly shifts and rotates, may - * retain sign bits on the left, but may scatter disconnected - * sign bits on the right. Retain only what remains to the left. - */ -static uint64_t smask_from_smask(int64_t smask) -{ - /* Only the 1 bits are significant for smask */ - return smask_from_zmask(~smask); -} - static inline TempOptInfo *ts_info(TCGTemp *ts) { return ts->state_ptr; @@ -173,7 +134,7 @@ static void init_ts_info(OptContext *ctx, TCGTemp *ts) ti->is_const = true; ti->val = ts->val; ti->z_mask = ts->val; - ti->s_mask = smask_from_value(ts->val); + ti->s_mask = INT64_MIN >> clrsb64(ts->val); } else { ti->is_const = false; ti->z_mask = -1; @@ -992,7 +953,6 @@ static void finish_folding(OptContext *ctx, TCGOp *op) */ if (i == 0) { ts_info(ts)->z_mask = ctx->z_mask; - ts_info(ts)->s_mask = ctx->s_mask; } } } @@ -1051,11 +1011,12 @@ static bool fold_const2_commutative(OptContext *ctx, TCGOp *op) * The passed s_mask may be augmented by z_mask. */ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, - uint64_t z_mask, uint64_t s_mask) + uint64_t z_mask, int64_t s_mask) { const TCGOpDef *def = &tcg_op_defs[op->opc]; TCGTemp *ts; TempOptInfo *ti; + int rep; /* Only single-output opcodes are supported here. */ tcg_debug_assert(def->nb_oargs == 1); @@ -1069,7 +1030,7 @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, */ if (ctx->type == TCG_TYPE_I32) { z_mask = (int32_t)z_mask; - s_mask |= MAKE_64BIT_MASK(32, 32); + s_mask |= INT32_MIN; } if (z_mask == 0) { @@ -1081,7 +1042,13 @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, ti = ts_info(ts); ti->z_mask = z_mask; - ti->s_mask = s_mask | smask_from_zmask(z_mask); + + /* Canonicalize s_mask and incorporate data from z_mask. */ + rep = clz64(~s_mask); + rep = MAX(rep, clz64(z_mask)); + rep = MAX(rep - 1, 0); + ti->s_mask = INT64_MIN >> rep; + return true; } @@ -1807,7 +1774,7 @@ static bool fold_exts(OptContext *ctx, TCGOp *op) ctx->z_mask = z_mask; ctx->s_mask = s_mask; - if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { + if (0 && !type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true; } @@ -2509,7 +2476,7 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op) s_mask |= MAKE_64BIT_MASK(len, 64 - len); ctx->s_mask = s_mask; - if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { + if (0 && pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true; } @@ -2535,7 +2502,6 @@ static bool fold_shift(OptContext *ctx, TCGOp *op) ctx->z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh); s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh); - ctx->s_mask = smask_from_smask(s_mask); return fold_masks(ctx, op); } From patchwork Tue Dec 24 20:04:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82A1FE7718E for ; Tue, 24 Dec 2024 20:16:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9x-0002n8-8x; Tue, 24 Dec 2024 15:05:41 -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 1tQB9p-0002kh-Iq for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:34 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9o-0002Xs-5k for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:33 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-21661be2c2dso51061105ad.1 for ; Tue, 24 Dec 2024 12:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070731; x=1735675531; 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=ntKzLXVCf+dfdJqwHevl/7NkCe78JheCkwV4PXcpwhs=; b=Unh/ig9G8US+z/9RSgAEzWn1xkrz/udN6OUZb20HfBuV+VPNbwG1Q2h49hTLyFq8iX wLJL3lMu5kZw2560Gf6uJoK1zYc01SpkECZ3edevYhZ+cCs6cux5GTYUCZ45jhB1Dm9+ NYT5CkFSN+5IRAzE8rSCt1+e8p7yOUiqUJ9XoP5yc2gtVEgtA7OhvsZmQq53MLdhyKL2 A8qqJOf8eR5mogiY8VYuggdTpNXut7M7fju7TDF1hTf7PLmMiHA14vzKu8QOwQPz4VLu 30xT4AglLB8CN9oNWqMRbwUTUeemanAwC93uTA2OeygBZyxuMBNRdGKiKSAAg2plHSAI S75Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070731; x=1735675531; 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=ntKzLXVCf+dfdJqwHevl/7NkCe78JheCkwV4PXcpwhs=; b=UFHWZsxuCRM5V2F2NY5YRf56geIHYhZjDEgKk40rP9F0GkMMm4LY2etPjxljzsqSjS kYbbOYjBNDqxyJ9ZFoCMOSUaxAV8UKyrhO+2ZgCqnkVSbeFGisbXqQP+Sb2J23YSxCxH d8ca/r3ESyRet+2+j8+DcyDc3bh/w1PP0cm0y+05WrTLNYW9H0ISPqPxW8Bx/sCwJJXM MUgB2bh0LCGBW5e+iCzzR/uE/VJztlcZE+Lismj2vi0A/J+xLyDn7kObd1sJA1pxqMFo ViTfwJ2jalm2TUj92LWX2eaBybhRLVvX/1RexN4w3+MP5T7tPSxWLDT2x71zbLMUUxKi v7lQ== X-Gm-Message-State: AOJu0Yy3UGZzaaYRvRUv7R3BEMyXapjz2b18H1GFF+M3Jw2fY93FrYuB WrBS/ZX9+Yw+FTkG6UiX4FtHs7gWhefqiihrAsYHLjK82FamA/hUdXcjbcuw843rpiKs5DEeegp Z8lM= X-Gm-Gg: ASbGncuu2Hkl3xCLutLEvjqZNY06jOIs/3raMf21ac3TxXFATRyVnpVMK5vradw/O97 fuSylQRWFi+XUHmhD6epJOX8WMAs5oN68gWAWFy26s46V0G7mu+IpAkZeTe/1b50cE4dj6fQru6 e+uAy0n4bG0mKPlH+BKRmJ+2lEK8FOY7C1SQIq/KJMZCiNjI/5rvDQP3HTSu+Vm+/fd7WPtKUTZ Rr+An7fv8fOIoD+nkj/7kew+pFGnG7RydzAxhdgFqCHY0s/yrxFA4xGuUg0lgz92SHL5JWkryUk tfv39ewjkAPYCOJUUzkaWLBkSA== X-Google-Smtp-Source: AGHT+IGzMIJ6Mlk2jxXTdAi5fsSe7a8ApsMFdGhI9MtvQSMQMFPj0jlbvVQYiwmUPhxW4vTNPGVODg== X-Received: by 2002:a05:6a20:430d:b0:1e0:cbcf:8917 with SMTP id adf61e73a8af0-1e5e048ce0amr24611347637.21.1735070730797; Tue, 24 Dec 2024 12:05:30 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 09/72] tcg/optimize: Use finish_folding in fold_add, fold_add_vec, fold_addsub2 Date: Tue, 24 Dec 2024 12:04:18 -0800 Message-ID: <20241224200521.310066-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index fbc0dc5588..26d1c5d4a1 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -938,7 +938,7 @@ static void finish_ebb(OptContext *ctx) remove_mem_copy_all(ctx); } -static void finish_folding(OptContext *ctx, TCGOp *op) +static bool finish_folding(OptContext *ctx, TCGOp *op) { const TCGOpDef *def = &tcg_op_defs[op->opc]; int i, nb_oargs; @@ -955,6 +955,7 @@ static void finish_folding(OptContext *ctx, TCGOp *op) ts_info(ts)->z_mask = ctx->z_mask; } } + return true; } /* @@ -1188,7 +1189,7 @@ static bool fold_add(OptContext *ctx, TCGOp *op) fold_xi_to_x(ctx, op, 0)) { return true; } - return false; + return finish_folding(ctx, op); } /* We cannot as yet do_constant_folding with vectors. */ @@ -1198,7 +1199,7 @@ static bool fold_add_vec(OptContext *ctx, TCGOp *op) fold_xi_to_x(ctx, op, 0)) { return true; } - return false; + return finish_folding(ctx, op); } static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add) @@ -1265,7 +1266,7 @@ static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add) op->args[4] = arg_new_constant(ctx, bl); op->args[5] = arg_new_constant(ctx, bh); } - return false; + return finish_folding(ctx, op); } static bool fold_add2(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08547E7718F for ; Tue, 24 Dec 2024 20:07:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQB9u-0002lv-Ic; Tue, 24 Dec 2024 15:05:38 -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 1tQB9q-0002kp-TR for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:36 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9o-0002Y1-V3 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:34 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-21649a7bcdcso57354525ad.1 for ; Tue, 24 Dec 2024 12:05:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070732; x=1735675532; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=MvL7unhiDd3lPuRXr6mq82bN6R8xw9zcqDFlejItlQ8=; b=YkAKyEFepi1p/NeYSv+IOTBD0qRrkdC9/sEd6CrACfgjNhpTEpEvXZfIdbIGtJI+kL tmD/KuAK53eZaotCkhOBWHoeYQJ05u/kIiQ8BnD51+nQDx41CgazTUvZQMahV5GZrGN6 WDHMHCXOAVzHoCrvxGDzQ0WPzg66T9G7kXO0bTrUiJ94E6AIg/QAGq6ZVi23qKwFIsuW aZj1AGl4ebudsogynIS/BHJMxniucyTCL95IIRbDu6rJL5ioTHZYO/EIs6aUNmSsK90C yyGAL1yFWK7lM0tawhauPEv7THWbIimnoU/O72ezFT1lE6oZ1pNkjXwMyZf54Lp6acLb b+kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070732; x=1735675532; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MvL7unhiDd3lPuRXr6mq82bN6R8xw9zcqDFlejItlQ8=; b=RDLEhlX7kq/YAp40EZwuMrHWSM95/a1SgNwS36nhII+Ighil1jXfZh+XDjZQcJDusj c5bUodfNJtoxkULwxqKj4j+EsV4LPwrbjrTAV9ShJFHYisXkEibBQALm3v9jYBaFvNm/ 06oOSjMODtTbYK7lHHktFza41TLfckbkwb+VtJyW+DoHID7E3pj58GD3hOiyenbgpftz W6rfibIDCVsFLdT8+YUoCzTAPV1f810Ly6Q8+Z1HeFO7PHXYRUxN3jvvjZzwAxcBFCGx 73dE4wKkR8cs0konGtypoCu0gqwk/AmgFTQievzDqdgt56tFlbnF38scjgwIX2NLp/1b JkSw== X-Gm-Message-State: AOJu0YxibKUj8OOGAicXcUoYyt63c5aTrA9du3vaf6+urRTDLdlbCChg y0n7KGRbjZP5toam1F1gcXHrak5Dp+rSBrRxsdtdWwcj7tI3ZETtsiQXUWFCblbyIUzZB+8ZMO/ nebc= X-Gm-Gg: ASbGncuA5EJZC6SGvBe7J08SUXe2aIA3FCkY/zFptly5yR7d70orfzOB5Mu4b27wG08 WzG1XJSqBORq+BTmqJK9c97t2gW75tJQwy+S2MEqcj1t12HHC+190rf9Ec8dBXzJM8cpH6d7GM4 iIqN/bv4ODkGTXGdofNLWAC+OGO9k+PzuYC5G4oS/HYcpLyb1+BC1IqHRdsAveRceL5zT7XkTJi ecMJBXCeodQYcG9gKnm5bwoP9W9miJoZHlMIfK2aExCGe1NpQy2/u1L+AsMEvIlvZgv0zuIhDjw 9/IZdc3G8td5xoYG6noSPmGA8w== X-Google-Smtp-Source: AGHT+IGlX3g0MvRaO6P/lnK4DKugPeSK3ZhiOpZsbNYpmcU0lge7Ar+61RqRxOqKnfllyDz2ch3g/A== X-Received: by 2002:a05:6a00:4ac6:b0:725:e015:9090 with SMTP id d2e1a72fcca58-72abdea0803mr21685710b3a.9.1735070731748; Tue, 24 Dec 2024 12:05:31 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/72] tcg/optimize: Introduce const value accessors for TempOptInfo Date: Tue, 24 Dec 2024 12:04:19 -0800 Message-ID: <20241224200521.310066-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Introduce ti_is_const, ti_const_val, ti_is_const_val. Signed-off-by: Richard Henderson --- tcg/optimize.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 26d1c5d4a1..5090f6e759 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -79,15 +79,29 @@ static inline TempOptInfo *arg_info(TCGArg arg) return ts_info(arg_temp(arg)); } +static inline bool ti_is_const(TempOptInfo *ti) +{ + return ti->is_const; +} + +static inline uint64_t ti_const_val(TempOptInfo *ti) +{ + return ti->val; +} + +static inline bool ti_is_const_val(TempOptInfo *ti, uint64_t val) +{ + return ti_is_const(ti) && ti_const_val(ti) == val; +} + static inline bool ts_is_const(TCGTemp *ts) { - return ts_info(ts)->is_const; + return ti_is_const(ts_info(ts)); } static inline bool ts_is_const_val(TCGTemp *ts, uint64_t val) { - TempOptInfo *ti = ts_info(ts); - return ti->is_const && ti->val == val; + return ti_is_const_val(ts_info(ts), val); } static inline bool arg_is_const(TCGArg arg) From patchwork Tue Dec 24 20:04: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: 13920493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EC58E7718E for ; Tue, 24 Dec 2024 20:09:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAU-0003O2-1X; Tue, 24 Dec 2024 15:06:15 -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 1tQB9r-0002kw-J7 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:36 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9q-0002YC-4j for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:35 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2165448243fso66700385ad.1 for ; Tue, 24 Dec 2024 12:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070732; x=1735675532; 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=hpqpgVCVgx0sIQuZRDJGY03SPPXo8ssS0CTWPjNfIQM=; b=Tx0ERFhmSuQSAnPUkhaOkpsKzaU2ICcLwa7+EWwS6qbL5L2nebL8EbOXPqBG74czwM 1DlSQFHk2dQda+X/etHqVJSqLcXrnwdOxk+dT3ja585O4ZlGA3MhU5nYwF5P0+F0uO4l n86GmhAPX+3mvzBbGeIqTIns6JFqZyxs6AKfhMIasQWeI5mWZKsT3GuWLGZbVMh4UVdv QmC3/Z+E/6bKapKryT8Q780jjuWg9RmvxaMOmgK0x6Y5V0vOkrAQEsZ4DgmCO/e1Kf5Y 6EYyf+hx/pB5RAA8bKo04y+L78tEMVgUbfJT18FEygD00ISnMve+6piE4W4KAe3ui6Me V9gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070732; x=1735675532; 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=hpqpgVCVgx0sIQuZRDJGY03SPPXo8ssS0CTWPjNfIQM=; b=ducOX/NDk9suXOYdhsuDA9NDKcuY2bpK+0dVCg85pfSHPI+8ECMVtkCkGiBAn3US3t MMro4ZF2Sf2GttaAafgnyDHmLtVFkCPm24qNYzFIMgk5fiJkxNfYDng0heHQ+s7VVimb FlsfK5IB24tzAU5SGIaqLa0OaeOU2KTl94xv6NhCcZDixE/wBUt2oMA+TABkQu7uAD9I sK7rnt1WBNVDv8exESMvjJ+l89Me0q5rVJiv+SKExmnnAQ4kvG4V5loqnjHbX15dYkuD bEiIoHfM455vNkgGCrnjrJedURvywT2EFsqVImSJiWR40rjnnxODbjVba4GmUmw0FXmL GgsA== X-Gm-Message-State: AOJu0YyLxlhZJ+ircqRk++Lk/qilngZ8+k4IXKturwnploc6aDYjlf6x Hlw6f6qwiClaLaSeIy0KI4U7m05wmoYYeGFPj5mMDueBqvGaSfMjuYtG7STQfGko8H+YoiDI7Ga v01A= X-Gm-Gg: ASbGncsIvmsmojE085m8AykEwae+ZeoCWK/7lX/75j1hvcilz94aWNJ82s99YLAFmwD nAqVDFanhgkzJRRrRx4pBuO61gPoPqcSUZX2pP4zZaq/bVsARbQXivTev+Tn5829ujMW+Ntwx6r xxoOXkAeUs7N4ei/aKm4B1Gwi2du6bKEdtphySUOr/WkzBq+iePrFVQxxmArQEeVHrqZ8NTTiPm oyr0U0K/Cm+5LIWOBinu1H6If7o0CLnblskOckalNYBppMgfXzIf39o5iTL6wQB+1ZeO2WtI3EQ CP99Z4HYDna56XpeaLL87ThBQg== X-Google-Smtp-Source: AGHT+IHIv/5qI5sgC3qnRqI/s9YrpHiU69uSTCw74PQ79sbECIVOW1NC6Ew3wnS0DWwHQH1HOInm5w== X-Received: by 2002:a05:6a00:8085:b0:725:e309:7110 with SMTP id d2e1a72fcca58-72abdd3bf64mr26835076b3a.5.1735070732617; Tue, 24 Dec 2024 12:05:32 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 11/72] tcg/optimize: Use fold_masks_zs in fold_and Date: Tue, 24 Dec 2024 12:04:20 -0800 Message-ID: <20241224200521.310066-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Sink mask computation below fold_affected_mask early exit. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 5090f6e759..4a5b52916a 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1294,7 +1294,8 @@ static bool fold_add2(OptContext *ctx, TCGOp *op) static bool fold_and(OptContext *ctx, TCGOp *op) { - uint64_t z1, z2; + uint64_t z1, z2, z_mask, s_mask; + TempOptInfo *t1, *t2; if (fold_const2_commutative(ctx, op) || fold_xi_to_i(ctx, op, 0) || @@ -1303,27 +1304,28 @@ static bool fold_and(OptContext *ctx, TCGOp *op) return true; } - z1 = arg_info(op->args[1])->z_mask; - z2 = arg_info(op->args[2])->z_mask; - ctx->z_mask = z1 & z2; - - /* - * Sign repetitions are perforce all identical, whether they are 1 or 0. - * Bitwise operations preserve the relative quantity of the repetitions. - */ - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; + t1 = arg_info(op->args[1]); + t2 = arg_info(op->args[2]); + z1 = t1->z_mask; + z2 = t2->z_mask; /* * Known-zeros does not imply known-ones. Therefore unless * arg2 is constant, we can't infer affected bits from it. */ - if (arg_is_const(op->args[2]) && - fold_affected_mask(ctx, op, z1 & ~z2)) { + if (ti_is_const(t2) && fold_affected_mask(ctx, op, z1 & ~z2)) { return true; } - return fold_masks(ctx, op); + z_mask = z1 & z2; + + /* + * Sign repetitions are perforce all identical, whether they are 1 or 0. + * Bitwise operations preserve the relative quantity of the repetitions. + */ + s_mask = t1->s_mask & t2->s_mask; + + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_andc(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EA20E77188 for ; Tue, 24 Dec 2024 20:06:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAF-0002yj-MC; Tue, 24 Dec 2024 15:05:59 -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 1tQB9t-0002lV-0t for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:37 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9r-0002YL-9K for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:36 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-21675fd60feso73525435ad.2 for ; Tue, 24 Dec 2024 12:05:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070734; x=1735675534; 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=pZ0KIsF1BBfIHqPWVMCdpClBho97FcY+wzgcx7bn3Cs=; b=whvym1ejpDLxcBCimTNssEFz4EZQR1b1FBqicwIehHEDNOM78yqxhJFoqfUmPMMrNR ZJ5TEceHYkCxy2bB2MwgEV2zJAwLo6rNp+VMIqFis77Nh78720ASQHcDaSTifaR8BhZy diz0NOvvnEXB3wu6J6unSUVs0r6jO5XiAq987T+OOJhNK6ULjov1Bo4PrjGOxS5zYqE/ 2psBWewT6eztV03FaDP41w3eHAq/iq2h1L7/+UeL9cetcRhNxVpyjHqGHFOzywGmZi/M dJIn5vb9txUT0e5x36w+aO/KOJfH25uFxT51Z7sc5nzzJ1T08sMWApY1IX2L7jL+D/Dj NYOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070734; x=1735675534; 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=pZ0KIsF1BBfIHqPWVMCdpClBho97FcY+wzgcx7bn3Cs=; b=Oikatbx7Eob7MXCiUGIHuvkdBsVOJP+Ccsp9FZ6pT4un+xfTyhdryMh/jj187bZLRD FOl5KBuNxl+WLd/9leGqQHYOn7R485higaDDgUFi+7yrSPY962b7UpBvwiFtvAeKJSRF IKk4WDXOJyhxm1NH1VflRyND0iekUjyaFQ1lyRAUycXDUxEiZ2XJXe+apddddNwhGZjD /yU217GjdZYJtWVzcc0oFpGvpaLfzVmPADY1M9Vu30gJqhwoZRmeuFiBoRvNDgsQCvrI rbFWuFH769fTUfSYrKOZ0otGomvHJbbXYl2DLbTvqNx498RP1SK5smbt2qAKKrdxHttf QMPA== X-Gm-Message-State: AOJu0Yy+xMjmbpIxHys91hKP2ZWpPNWS2Zvq/2ok2gwZVwPA8il/UlD9 wPb7A1eo/6HubgcEC7vPLEyjqo2qEW/sqCPyY8/AqUaNdx4B9gHrnFPWf/p8xDtFiqFIE2Qr9C4 Bl4Y= X-Gm-Gg: ASbGncsN8AdKACo5QuqXsP/sLjKo8HG421Fx3pKz06x+wqo39MSVzXkB1sGi6YKY2zi 0ovisD3nSFMajEPZv28dufmn3ws3roPEKOfsxiNkXvckAx4pZhbQlnG22Xt75yB1UiE/60Wj9Pw kyUVyQF3K21/57kl47FWnuIX5fj7WfuCj695FrL7OaDFCUomqtjmvwnm5Q18b517T3FOcTlZxji 3frNe5JPqVWtX/29ahXDVyoWUrR0GUzd1JdxPb/8wvyFhX0NQ33jXD2Vr3vP9ouh8m37Geqayg7 nthc8Y8yoEjh9/F05Mv23tZhfg== X-Google-Smtp-Source: AGHT+IGIWgRL/q+1g+3i/m8GQzdib+BNDdR7mA6ZObrWwJsi2Qg3Ibe7bFpEO3CbfHoo9+tDSJRsYg== X-Received: by 2002:a05:6a21:1014:b0:1e3:e836:8aea with SMTP id adf61e73a8af0-1e5e046f453mr32506448637.14.1735070733786; Tue, 24 Dec 2024 12:05:33 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 12/72] tcg/optimize: Use fold_masks_zs in fold_andc Date: Tue, 24 Dec 2024 12:04:21 -0800 Message-ID: <20241224200521.310066-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Avoid double inversion of the value of second const operand. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 4a5b52916a..2096d705bd 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1330,7 +1330,8 @@ static bool fold_and(OptContext *ctx, TCGOp *op) static bool fold_andc(OptContext *ctx, TCGOp *op) { - uint64_t z1; + uint64_t z_mask, s_mask; + TempOptInfo *t1, *t2; if (fold_const2(ctx, op) || fold_xx_to_i(ctx, op, 0) || @@ -1339,24 +1340,24 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) return true; } - z1 = arg_info(op->args[1])->z_mask; + t1 = arg_info(op->args[1]); + t2 = arg_info(op->args[2]); + z_mask = t1->z_mask; /* * Known-zeros does not imply known-ones. Therefore unless * arg2 is constant, we can't infer anything from it. */ - if (arg_is_const(op->args[2])) { - uint64_t z2 = ~arg_info(op->args[2])->z_mask; - if (fold_affected_mask(ctx, op, z1 & ~z2)) { + if (ti_is_const(t2)) { + uint64_t v2 = ti_const_val(t2); + if (fold_affected_mask(ctx, op, z_mask & v2)) { return true; } - z1 &= z2; + z_mask &= ~v2; } - ctx->z_mask = z1; - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; - return fold_masks(ctx, op); + s_mask = t1->s_mask & t2->s_mask; + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_brcond(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12524E7718D for ; Tue, 24 Dec 2024 20:09:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBA4-0002ox-PF; Tue, 24 Dec 2024 15:05:48 -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 1tQB9t-0002lj-Ja for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:37 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9s-0002YU-3n for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:37 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-216281bc30fso65715595ad.0 for ; Tue, 24 Dec 2024 12:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070735; x=1735675535; 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=xHQE8MNsLMMkg9lb7/TKEPUriJ232hDu2DMvoc1Ulx4=; b=KBpfssXZ+7DL0DZuitWLROndsVlwi8iEIErFJthoTod7MtKVnkBgL2O3tJWR0+dS8w LAMHKNynTqqAC5F8HxeXX7GIcH9QEPlvcub8FjvfEiWAOLkOyGfX9MSop/rZrqN0aFid guFgbLEm8q9WCEoFpOletrfYB72NV3QM7W5yF5wrpdjxf0rWzs63nr2DWNdKZlT+aNg2 qjLljy4Bv1YwCuz4TCYUJR21UEBlp9vnvp+DIJhlvbOzyaup6JMHV7/jrYZrebj23QlN kyFPDckjTpiBu5CCMGk+/+qNYD8acOcK3hcm7V+Uaz3PqhtDWH6gCqOMZj01hUH7Lq1g BsiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070735; x=1735675535; 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=xHQE8MNsLMMkg9lb7/TKEPUriJ232hDu2DMvoc1Ulx4=; b=OBlhoWheXXltMLprWBx7uCynznSNLXPFb/D5ViR4CMWk/9N5qRKcUH2RSbzWTdCzak hMge7g8zq819oFYSoDkj3AiKbnDm1hKAq6fx3hi69eRlM8TX4iXT2SFVEl6OERgGFvFI w3oHiuxBFiAycKdoit1cbuVtdgdWUN9Jpc4J3AMsA3rtTNLgNYD70CXSmFypJizL1I7G pimohLqN2fhdcvfGXMIUCGegu4Xkhxl0Omyy692myfbdONlDU0Ye7lHvhLkQrQzXoi57 jkOBAjToRgwor42pVjjVW+ilnIEAuUQCe9/th87chFFV3/fOe36rPcziz+w1Kn83FuYz DGfQ== X-Gm-Message-State: AOJu0YwGXLc+zLgCmFjdDuRnGWyAphdDrxWC7cJvXirL8BgvWm3monu2 2oC3KNL+HJaUyWt9N8wl7dOl3k5zSnFRFBllpDNyN2xUcoZwLGhbrAjKYzIscTZjT0BWSX+844+ Y1jc= X-Gm-Gg: ASbGncs4Nl1kq1tMdC1J44aN7dHgIHefMq9KyWVW6jTLEXmV8cB/LiVvQabjWBNXxtm w57Lo3bVKM9R07KJdpF0755W74RpHtPOSGSANe+CIF0ybxrEd1z2F6DLZdprFWD1nZZGrHGq2Rr QkFe1NK9P8Sf/2vhVWR0zsUlCIj9pF6C6bGckXlkFtstsyqPJm8Z7o/nyv5jkvRSNkLLjiCQue8 AniwbUd56i9iBeOK3DOr76tfbdlC5tDYXoyyXmw49vAz8tp27+YGyJsScrR4TM0kbO1o81HylY2 VL9lelXbKa2B3XHVXDxdsTf5pA== X-Google-Smtp-Source: AGHT+IGfG7AS/QNH4Nebwr8deUzTfPxn8UJNPvVZZvePxgTHTodBSa5ExNDVhjJbzZtRaDT26tKxqg== X-Received: by 2002:a05:6a21:6d86:b0:1e1:932e:b348 with SMTP id adf61e73a8af0-1e5e080cb76mr30131289637.41.1735070734850; Tue, 24 Dec 2024 12:05:34 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 13/72] tcg/optimize: Use fold_masks_zs in fold_bswap Date: Tue, 24 Dec 2024 12:04:22 -0800 Message-ID: <20241224200521.310066-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Always set s_mask along the BSWAP_OS path, since the result is being explicitly sign-extended. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 2096d705bd..054109d347 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1477,16 +1477,16 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) static bool fold_bswap(OptContext *ctx, TCGOp *op) { uint64_t z_mask, s_mask, sign; + TempOptInfo *t1 = arg_info(op->args[1]); - if (arg_is_const(op->args[1])) { - uint64_t t = arg_info(op->args[1])->val; - - t = do_constant_folding(op->opc, ctx->type, t, op->args[2]); - return tcg_opt_gen_movi(ctx, op, op->args[0], t); + if (ti_is_const(t1)) { + return tcg_opt_gen_movi(ctx, op, op->args[0], + do_constant_folding(op->opc, ctx->type, + ti_const_val(t1), + op->args[2])); } - z_mask = arg_info(op->args[1])->z_mask; - + z_mask = t1->z_mask; switch (op->opc) { case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -1514,18 +1514,17 @@ static bool fold_bswap(OptContext *ctx, TCGOp *op) /* If the sign bit may be 1, force all the bits above to 1. */ if (z_mask & sign) { z_mask |= sign; - s_mask = sign << 1; } + /* The value and therefore s_mask is explicitly sign-extended. */ + s_mask = sign; break; default: /* The high bits are undefined: force all bits above the sign to 1. */ z_mask |= sign << 1; break; } - ctx->z_mask = z_mask; - ctx->s_mask = s_mask; - return fold_masks(ctx, op); + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_call(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49EE3E77188 for ; Tue, 24 Dec 2024 20:08:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBA8-0002po-HE; Tue, 24 Dec 2024 15:05:52 -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 1tQB9u-0002lx-NI for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:38 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9t-0002Yc-5U for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:38 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21628b3fe7dso53747255ad.3 for ; Tue, 24 Dec 2024 12:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070736; x=1735675536; 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=u/uXovwT+peKJg+4w3zvH44hwa1dOgTurwD+a66/j/A=; b=AF91Q8OV/RUZhcV3F0f6yyryH5Ut3fTIDNfgEafA7pQIkz9AL6WHSLjdZ0E/zRPhf0 gH+2q9IrBvbRUuFuio9dg/g/6BLOTYcleSJdpFRCGYY/C/uc3imLH1mVh2EI79aeZpte zZ1+u1PnriNquBED8CiOvQiRRGzKKhaRjQwLGIcBpfPKfvN4KTsa6thJ3eJB2Z+EviZ3 zv30Wnw0930dvEX+SoAJ1a1Aur43G7EybIUHxFWHvIYRSjd6VdUSTFlLiBEESPQMgBUz W3MZrwMxaUitfMBxp+PczFyyIg13zHafh3FF7yofSN85MM8qgraVir1IsDrKhjZfNKIj zPbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070736; x=1735675536; 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=u/uXovwT+peKJg+4w3zvH44hwa1dOgTurwD+a66/j/A=; b=WCRWJ0hS5Qc0N/8FCmImpqoQhfrmAvz8voHNL30fJf2z5TrFYImpgTd9ZrN5/xSZYy M0m43RLbN4MpsnuemGbhKcm3O+BoGzk3Sl0nQtG1G3FIVNqsvTh3K8c5I5j/Bv48E6M/ sEzdRdn0Mo0SGes7P7LocCOs4wLG9l5sAl88JzhSXuVcrO9xaIGCueP1r2F5b0VHo4Gh MqU1vrBRnWwC5h/nblXK2xBalIf88+lPVK2PE9bpoxnY31nfmOAsU3yuw5ntuc9egZ0G mKcirui55y20vkhE0dc/nK0qf0GiO6jv3xqq0x0yfDTX/ufTasMKvvnga7RenUukA2Yj kDoQ== X-Gm-Message-State: AOJu0YzNUrhH8/Yl65YE8PpjZvaP2dKm4ncMSld909sxbPy9+gLS2nL9 Vto0FWTGxoXLFFK98iU0DVkgGLakihBMsywIlOvim39gbLjIzGzNhxPO/OgKbDc86XCONrqeZUV AWcs= X-Gm-Gg: ASbGncvwZbgYP0X49Fz8kUFIyBmH31Ah+i45TGVVFXa4rrAQAoMMt8/UT+Q6F/RlSuQ gQ+t2VK5i5Vs8Ur5CbgPQFm4avWflNMHGAFudnkD1zWe+sO74RSEUDxkF7hvYlMkHeimPreSa41 nignGMnBDlaIT1QjKyrcIH+mi3v1QOMC7DYfQYkdtC47cIlw6I7RXrc7MjHQQ57GRggwmO32Y6C tOOHxLxLZLrCAFi3ggRLVCaN5TytlwT+7nXG8SjrL7pejRfaqb+M9TSRs3CN1qO2LJxP9JMV7// Dmr94M8I8ZBA15XLYAL7Wuhobg== X-Google-Smtp-Source: AGHT+IGYu6HQZOrFX5XlLQJEN13CA/IEw/693zbVd+jqpSO6bK2B7EDsYe9fVG8mQzejx2aAZLWEmA== X-Received: by 2002:a05:6a21:3a44:b0:1e0:ca95:3cb3 with SMTP id adf61e73a8af0-1e5e083e416mr28581928637.37.1735070735680; Tue, 24 Dec 2024 12:05:35 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 14/72] tcg/optimize: Use fold_masks_zs in fold_count_zeros Date: Tue, 24 Dec 2024 12:04:23 -0800 Message-ID: <20241224200521.310066-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Compute s_mask from the union of the maximum count and the op2 fallback for op1 being zero. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 054109d347..0766a452b5 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1566,10 +1566,12 @@ static bool fold_call(OptContext *ctx, TCGOp *op) static bool fold_count_zeros(OptContext *ctx, TCGOp *op) { - uint64_t z_mask; + uint64_t z_mask, s_mask; + TempOptInfo *t1 = arg_info(op->args[1]); + TempOptInfo *t2 = arg_info(op->args[2]); - if (arg_is_const(op->args[1])) { - uint64_t t = arg_info(op->args[1])->val; + if (ti_is_const(t1)) { + uint64_t t = ti_const_val(t1); if (t != 0) { t = do_constant_folding(op->opc, ctx->type, t, 0); @@ -1588,8 +1590,11 @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op) default: g_assert_not_reached(); } - ctx->z_mask = arg_info(op->args[2])->z_mask | z_mask; - return false; + s_mask = ~z_mask; + z_mask |= t2->z_mask; + s_mask &= t2->s_mask; + + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_ctpop(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A345E7718F for ; Tue, 24 Dec 2024 20:08:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAS-0003Gr-G6; Tue, 24 Dec 2024 15:06:12 -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 1tQB9v-0002mD-Oi for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:40 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9t-0002Yq-W3 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:39 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-219f8263ae0so23702555ad.0 for ; Tue, 24 Dec 2024 12:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070736; x=1735675536; 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=LsfMpsMqMxq0FC0omwsdymCcUELXX5bANXU+yD+lCsQ=; b=Djw7fbvCvS95UCcvWdkqoDt401bZcC08Sohu8lmFAL0o2NW0oNCrxLhyZ/eKEnQLLH HxGW2Z0wjVFbQep2dUcYc1RaUvPWEz6RsBoehleLdNj72pefL0Wt7SNi3yClFzY0r1oC wpn7pFDPRu3Mz94f2Q/sb+FpC2IVAy0xS3SEkHD/BBP/dOmV6K028ValZw+Oaeu7BMuP TF6qNbZoICc0my4iuIQl2WFO4oi1/TtHCJGPppreCtB57JpM5/zY0caiwe+93i+gHrsl x6jVYg6Zh6zhsApB9kPjbhBCsM++y6aY8yJ4ZKDH3na6pJxD+aQKoIUEUajpy4adYCDK hv7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070736; x=1735675536; 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=LsfMpsMqMxq0FC0omwsdymCcUELXX5bANXU+yD+lCsQ=; b=M90fbkuhAkClrXFczqSMMbdJi97Y99VEkWU42QXv7zqJKRV9skXA6RL0k52xvhikEb P0fBaTySftpwSSCkW+bQ4ROp4z9bpngevyRgr2/xy0vgtRyJn3v3VsmiKkWvgpgPo5s3 Vkx9ZYJCq2mu8drt0s7tgNNBpEdqaf7yIq46/3WAs2JFjfWWAOoTK+/QLhD5KOcK7icj RV7Wb96dvxA0Z6PIWp9JeLwOyrSLa0uvONozgOlYveOXnvmibEYxFBT/7SrgyBmh9EGK zgU3YDcfAISSVcPHFvGLaaPIjKPkA0urLHzKTuwtWpvxuFwmpfqAEWgZ2VSNFiJAhKW0 vo0g== X-Gm-Message-State: AOJu0Ywqa+kVM09TgIeEmRu8vAMAkY6ayV0qTElnKlBzIpQZARjXMq+g NbJ5jh1RwygBO10K2+BFSt7HtRJdWV551Dh0UMRUP1KxHfsI2YqmMO2LU4F0tIgI03A2MfPFgx9 k13w= X-Gm-Gg: ASbGncsA8XzLI+W002O+K5GGf755XaeiJM+yDO0UQVf+ewnY6wTAFq95WL+pDbwGfSj r/3Sfi3G+Oa1n8UyhB+xeJTdDtJxelVr4/3oyzAOhM76DGo8orlAy0SNrJXNLZ3d9QZovlt4kQ9 /t+wD+RBlDDdW8DQZiOc4n+ykctKtfELYhmn37eFrmnlClr5AVvXucZUj4NSI5Ko8EYtM+38ejy KaVbLC+BPvxX6yC4B0rDrTw0Iry9RYddLF/h0FyJHt562nR+fuuzzUHafakFYeLVucQn7zABmxa d4tcBD2Jy5BAyjLKPf+4UOavaA== X-Google-Smtp-Source: AGHT+IG2U84kseABWX3u8yzvXMyQp6VOXzW9uEWSyT8xiQ3hhJWZvBHYGOUvrkFpbkDoTp4sBhbemQ== X-Received: by 2002:a05:6a21:100f:b0:1e1:a693:d5fd with SMTP id adf61e73a8af0-1e5e04a3432mr29074598637.25.1735070736528; Tue, 24 Dec 2024 12:05:36 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 15/72] tcg/optimize: Use fold_masks_z in fold_ctpop Date: Tue, 24 Dec 2024 12:04:24 -0800 Message-ID: <20241224200521.310066-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add fold_masks_z as a trivial wrapper around fold_masks_zs. Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 0766a452b5..2f5030c899 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1067,6 +1067,11 @@ static bool fold_masks_zs(OptContext *ctx, TCGOp *op, return true; } +static bool fold_masks_z(OptContext *ctx, TCGOp *op, uint64_t z_mask) +{ + return fold_masks_zs(ctx, op, z_mask, 0); +} + static bool fold_masks(OptContext *ctx, TCGOp *op) { return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask); @@ -1599,21 +1604,23 @@ static bool fold_count_zeros(OptContext *ctx, TCGOp *op) static bool fold_ctpop(OptContext *ctx, TCGOp *op) { + uint64_t z_mask; + if (fold_const1(ctx, op)) { return true; } switch (ctx->type) { case TCG_TYPE_I32: - ctx->z_mask = 32 | 31; + z_mask = 32 | 31; break; case TCG_TYPE_I64: - ctx->z_mask = 64 | 63; + z_mask = 64 | 63; break; default: g_assert_not_reached(); } - return false; + return fold_masks_z(ctx, op, z_mask); } static bool fold_deposit(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD8D2E77188 for ; Tue, 24 Dec 2024 20:07:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAN-00037W-UO; Tue, 24 Dec 2024 15:06:07 -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 1tQB9w-0002mF-3v for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:40 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9u-0002Z5-JL for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:39 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2163bd70069so55718015ad.0 for ; Tue, 24 Dec 2024 12:05:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070737; x=1735675537; 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=sf5EKd0lXfaCbRbQXllEv2ceVywi3b3Vv26rFZxb6RY=; b=ng+ETRGZ/vMlNpAxuI9FwL6DX0sIRSEJx8/dQvJOTTdbuoNwWNFQfluhS4W8Jl6RgO IrxZO+bLw9Zg1BUgeBOv3RvThsOwT/1t5DJIMFrYg5rk6wVZoFZNIbT2SJMeYZ72Jgtp r3RTX3Uhr3K6hzXFRhaje8ZmDvnfBHqfZKPee320FgtjlKmLIgWqaLCksoCvzxi02BJw qUClGQ9xryXzabw3HP524PQ2UPKSrSRuBlU23WAA3lS6TYHLuyB8vLbUeQUrTdwTSyaT 1vXgTeZjDbS91YfN3gPEg32rkW2xO7kBlsVSDNE+734xp3Wk8LDCgel3xU+Lve/kN8YW vyDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070737; x=1735675537; 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=sf5EKd0lXfaCbRbQXllEv2ceVywi3b3Vv26rFZxb6RY=; b=I0CHAlUHyOiCT/rCGOj4W76Hl/gAAbLXo7UNF8StQRwh93f12LjABsJzCAXO+kSRoA LPKN1iQWlF7KQz7xyqUqbGChkniP/5wMlzA2SPN2GBIk0uqW7pjDUeMxvkK/twC7bRrv 8sSPcHEfPDemXGK7jpq29oI7dSK2OTtgm0flD7+Kf94i4iOev5zUy90KzRcue6FJzcvK VEtTR2eOawWBMDu5gjc1nqIg9I2GF1WvJbMmcpXg3X/fFjL6sYTozbYTqRT1zx3Ymtfo YZqKrqAsBZ3hX9032SchappBBYL+SHSHPVOhVQLfNbLpxW6Cb9zrOpu/yPSQjqSCeNMc 3NwA== X-Gm-Message-State: AOJu0Yz796HbG6g8gloeMMI1Nu7CJhE9qMpdlFEYgiWcm1Yx2aHFLBij RFBXz6FoLasuhM0FEMvh1ph+Mg860QaW+cnQnStuPMItKqP47Q5m7byVdtXTiWYhji4pdJod9hI 6MeE= X-Gm-Gg: ASbGnctasYs1biBC1lqEuaoPBj0/9Sn3Tp/xCIcHWVVrJ2gOj7fS/j7ZVa0V4OhUX6a mCGc4IlGOpIbljqio8KCQz/6/x1tcqQ+JNqo5cJLYVmefNApPAnz/7QkiLcVxpe68erVXVIXaqU /WBnVzNssgTW6au4wROUyAmrL+EX2LS7qu2NTfFV64XVHzOmvmvMfgU4b0QQuAeprxm8MAQY2/P QP7UUhx9O4rNigXNiiFl/zVGaqUTxfjFzBC0pisSX5PCGvdi12KxIQxije3dIhs6Vi73kA7cnEx U9BNStSpGenf90ooHbAXEa/v0A== X-Google-Smtp-Source: AGHT+IFDnUMJqjX/QnJt8oK905r1lE3ZtFYUmT6krWzZ4IsyVc7O7IwOJoaDdsZLTqYa9WRa3/GZjg== X-Received: by 2002:a05:6a20:c907:b0:1e1:a829:bfa2 with SMTP id adf61e73a8af0-1e5e05ac3bfmr27799976637.19.1735070737356; Tue, 24 Dec 2024 12:05:37 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 16/72] tcg/optimize: Use fold_and and fold_masks_z in fold_deposit Date: Tue, 24 Dec 2024 12:04:25 -0800 Message-ID: <20241224200521.310066-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. When we fold to and, use fold_and. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 2f5030c899..c0f0390431 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1625,14 +1625,17 @@ static bool fold_ctpop(OptContext *ctx, TCGOp *op) static bool fold_deposit(OptContext *ctx, TCGOp *op) { + TempOptInfo *t1 = arg_info(op->args[1]); + TempOptInfo *t2 = arg_info(op->args[2]); + int ofs = op->args[3]; + int len = op->args[4]; TCGOpcode and_opc; + uint64_t z_mask; - if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { - uint64_t t1 = arg_info(op->args[1])->val; - uint64_t t2 = arg_info(op->args[2])->val; - - t1 = deposit64(t1, op->args[3], op->args[4], t2); - return tcg_opt_gen_movi(ctx, op, op->args[0], t1); + if (ti_is_const(t1) && ti_is_const(t2)) { + return tcg_opt_gen_movi(ctx, op, op->args[0], + deposit64(ti_const_val(t1), ofs, len, + ti_const_val(t2))); } switch (ctx->type) { @@ -1647,30 +1650,26 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } /* Inserting a value into zero at offset 0. */ - if (arg_is_const_val(op->args[1], 0) && op->args[3] == 0) { - uint64_t mask = MAKE_64BIT_MASK(0, op->args[4]); + if (ti_is_const_val(t1, 0) && ofs == 0) { + uint64_t mask = MAKE_64BIT_MASK(0, len); op->opc = and_opc; op->args[1] = op->args[2]; op->args[2] = arg_new_constant(ctx, mask); - ctx->z_mask = mask & arg_info(op->args[1])->z_mask; - return false; + return fold_and(ctx, op); } /* Inserting zero into a value. */ - if (arg_is_const_val(op->args[2], 0)) { - uint64_t mask = deposit64(-1, op->args[3], op->args[4], 0); + if (ti_is_const_val(t2, 0)) { + uint64_t mask = deposit64(-1, ofs, len, 0); op->opc = and_opc; op->args[2] = arg_new_constant(ctx, mask); - ctx->z_mask = mask & arg_info(op->args[1])->z_mask; - return false; + return fold_and(ctx, op); } - ctx->z_mask = deposit64(arg_info(op->args[1])->z_mask, - op->args[3], op->args[4], - arg_info(op->args[2])->z_mask); - return false; + z_mask = deposit64(t1->z_mask, ofs, len, t2->z_mask); + return fold_masks_z(ctx, op, z_mask); } static bool fold_divide(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB356E7718D for ; Tue, 24 Dec 2024 20:07:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAS-0003HY-Jq; Tue, 24 Dec 2024 15:06:12 -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 1tQB9x-0002nM-Eo for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:43 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9v-0002ZL-OU for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:41 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21631789fcdso46982225ad.1 for ; Tue, 24 Dec 2024 12:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070738; x=1735675538; 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=djzRryUm4IchJk8S/iBXoENiUIgFlXm/HpsFU74cNpE=; b=rj/TRc9VVY6QbvLbxL1E2cw4rsQcxOV3IvQtzJnArArOsmoMkDDPV5kUq8Kt1UhvYB VHQWzgUXbXvHXpM8XNJ1gEs8gfsG+Wk8QeqRLLCcr6LSvmsWvZVw5dQO3xItLwnjg4VB ezK7mOCZQY/7SWNjrX04cEgLbXpKo9ALacXVPDO+Or3PgPj5Cq85NGEAuldRdb5UMnOL D7IcTstzDDGqV5V3+1mzoYCmu5JnyMu03PMy0eyANcSYRfqV6SD2njtvX7JfaKgTfFH3 xVDgV2exRo32/GodQDY+N2H6z2GASeBp66vTsrk6q+/pstFs89TKn2CUsTAm/nMb6Rg5 6d6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070738; x=1735675538; 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=djzRryUm4IchJk8S/iBXoENiUIgFlXm/HpsFU74cNpE=; b=XZndXuo6S6WLn9x5yOJBX6PODtDGULue6WuC0LSaZftczNKnkgUy+YTOwZktVsCHkg pHX34kdZ82BTA02wSpuPABloV8ZjYU0qKV3q8rgE7Gj7Uxaq15b6pqILHZ0GmZ1MsqTj 62GOGp/JHUZJO10wI6S0OLy6Z9fWWKGSYcjbakfuMrZ6se+ePKxsIQ6FdJCu265wy6BK NFJskJcJnghupCvadAvXhPUg/tAqiM+WMCVc0VzVpYZmfa3ERkr6ZY7CKiI4TjrQHfE3 DEEZjmYqkNsqOc0PAXgrTh5E3XV1c7F3NXQ33CTibOd315R5gNIv1oo6lpdDOKzWoGSs YDwQ== X-Gm-Message-State: AOJu0YyuY842gKf/H9KoI0nB68PVptCk+zo5bDhxK+7zkjgHbvIN6ZmD mqI3MfABkc1TbtWPmQyaiLdhU0RvUKxcW0sVyud8DhnrQ0y2eaoE4AsBLk1RXMNubniKmGejMBZ lZPU= X-Gm-Gg: ASbGnctolJUco0hXXJjCBGqd2M/tncRfV/F9t6V/7MM+XNK19gqIOVHPpHtel3Trls1 7GnsBzBH8sAnC8Li50w5FQo7bQmtxcRxbxqis9NXwvEZMuZZjYbvCoyWwShU/IN80ACKtC2VzFj sznBcen59y/84NFqoYjk7ephMhXti3UnDlEOBQ2vXoBhzhDiIQBBMzWmch1ATm06vDppjdVI8z7 84taNYFeDWwE+munmU3yJ9bozYNOrASmb/ylSIEJYJuTjNagYD9NuSx7UbaZkBt8sb/AmT/Ukxl 28acGFCwh42Yqss10EwAnuXtZw== X-Google-Smtp-Source: AGHT+IG5DCUeXwv9rxnBWMvHtKsNkOA42XQZhguRnI2A2jZ40u2cUsaSRCmVJIJRWD+RV6ANQ5vzVw== X-Received: by 2002:a05:6a21:339e:b0:1e5:f8c6:203 with SMTP id adf61e73a8af0-1e5f8c6076fmr14459488637.14.1735070738359; Tue, 24 Dec 2024 12:05:38 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 17/72] tcg/optimize: Compute sign mask in fold_deposit Date: Tue, 24 Dec 2024 12:04:26 -0800 Message-ID: <20241224200521.310066-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The input which overlaps the sign bit of the output can have its input s_mask propagated to the output s_mask. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index c0f0390431..b774c96f49 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1629,8 +1629,9 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) TempOptInfo *t2 = arg_info(op->args[2]); int ofs = op->args[3]; int len = op->args[4]; + int width; TCGOpcode and_opc; - uint64_t z_mask; + uint64_t z_mask, s_mask; if (ti_is_const(t1) && ti_is_const(t2)) { return tcg_opt_gen_movi(ctx, op, op->args[0], @@ -1641,9 +1642,11 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) switch (ctx->type) { case TCG_TYPE_I32: and_opc = INDEX_op_and_i32; + width = 32; break; case TCG_TYPE_I64: and_opc = INDEX_op_and_i64; + width = 64; break; default: g_assert_not_reached(); @@ -1668,8 +1671,15 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) return fold_and(ctx, op); } + /* The s_mask from the top portion of the deposit is still valid. */ + if (ofs + len == width) { + s_mask = t2->s_mask << ofs; + } else { + s_mask = t1->s_mask & ~MAKE_64BIT_MASK(0, ofs + len); + } + z_mask = deposit64(t1->z_mask, ofs, len, t2->z_mask); - return fold_masks_z(ctx, op, z_mask); + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_divide(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79277E7718D for ; Tue, 24 Dec 2024 20:06:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAF-0002ud-Im; Tue, 24 Dec 2024 15:05:59 -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 1tQB9z-0002nd-W2 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:44 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9w-0002ZW-SY for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:42 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-21631789fcdso46982295ad.1 for ; Tue, 24 Dec 2024 12:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070739; x=1735675539; 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=rao1rvqabzx7DLwVY1TOu70R+eSLvWsnttr4yGctDGo=; b=WmxItP/S7QF9ctcufawOtNDdiNWBk/r9fCflyMZZphYnqAqMclwARtRG/3AGiFVgAb 3REjllXoMo4g9Oz5neweLnErUvICTNKg3MePkz3cnRlQb1wvHb4Tvt+kH9TvdjHKtzkZ S0VINMdJyfiC5Zg5AJUnFr8zJQkzaZsUUT01fvDWuCcbQLnkRnlEWy5pIpEYqvvXbvG+ evN1DOeygnALbMYLxk7lix8lmFRgwz/kyCZtlsbSqLm3sA5x+GI/O0K/Ylcy7IFxtCgy /b3CC5pmXLIA4tAHDjEDqIwBglSRkJzZ0OpXLpIYcJ9ZBz0mOqj3RiN3q5xs4Kr1EgfD uS6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070739; x=1735675539; 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=rao1rvqabzx7DLwVY1TOu70R+eSLvWsnttr4yGctDGo=; b=Yq1HNW17z96wm7+zo7xykARo8OF8gLv263AOZ9Y67SwGGTLojKCMfm6MnVaC/WKXpV 2ztuij6WA5sEYfII7oq2Dno1d9KfOLSDcfd/6XNaXuToeVBdyQVZFmJirBBsw0nMXnIl cDTTETQjz9OrADbSWA1Pc59ShdXsCDczLYsjHGnKCg0ySd3FAe5s6FqfLyMrAwBvdET8 i5P3IkeMenSFDkgypYalCam0yGcklP7ZuJyIjZopIRk9QBrYRqYpbFi5NQC2uU8v/jyX XIQEhVfndEun4GuCk0KTQRgu4bbh0YTO1N6gx4x7OOX36hCvuE3ItNV6bBfXYKTCV40H eytQ== X-Gm-Message-State: AOJu0YycygkGGrxIDBAm1KAqB/avq+zWvlQBd7U3ffm7V4uovlAT8woJ 7cyxkBrzJkWwNovO4ypSM1a9NnEfkncoV/NXnFA5nrrpM4kl6znB6JsQvMVFyY1KejhOUtIZ5tU Hn+s= X-Gm-Gg: ASbGnctw4K+oM704jl1R20QA1iGUqgyANRkcLMQ+ITzvh3eSIlja6IY6y1H645HWfRZ qHweDMkFBxY2x9zDAxPOitFbJjY2TPpb/nH4fPHukzAAzj4QiP7z8O1KoDUtM+YoMWtq18+sK3E q8Kttko4URNoCfBh017JdbBPo28DmTtG8lfuXrTvZ9K/Hi9DuWJQRxyj59rnxHxzAAIoh2BDIN1 rpcQ8U2ouSDjO6sy2fCiuTpM3epcgNWEdtzdV/2MhlLRjC4GChp7xnIS9FrpTPin7/PQWLD80fP 6qyMz6aPiSklaMVcyn/3BUp5VA== X-Google-Smtp-Source: AGHT+IHYFzSImgd1G//M0utNhf5UnbO2e6Y/WuMcRLKsZ3NmbJNTZtZ9K7iYGy6zKBAtKk3Z9+bAZA== X-Received: by 2002:a05:6a00:21c6:b0:725:4915:c0f with SMTP id d2e1a72fcca58-72abdbd7f45mr24738959b3a.11.1735070739384; Tue, 24 Dec 2024 12:05:39 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 18/72] tcg/optimize: Use finish_folding in fold_divide Date: Tue, 24 Dec 2024 12:04:27 -0800 Message-ID: <20241224200521.310066-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index b774c96f49..a68221a027 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1688,7 +1688,7 @@ static bool fold_divide(OptContext *ctx, TCGOp *op) fold_xi_to_x(ctx, op, 1)) { return true; } - return false; + return finish_folding(ctx, op); } static bool fold_dup(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8905DE7718F for ; Tue, 24 Dec 2024 20:06:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAG-000308-FA; Tue, 24 Dec 2024 15:06:00 -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 1tQB9z-0002ne-W9 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:44 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9x-0002Zj-NW for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:42 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2162c0f6a39so64869895ad.0 for ; Tue, 24 Dec 2024 12:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070740; x=1735675540; 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=oEBb6lgw9CBGrH+fdl+vxQW2dmf3GxJ+EO5jjQIVvNE=; b=A289RmNwd1/g8LiAnGRSsEqJ/ROtkw+Pb06Uq8Y0ru2e/I5y2UxHf95ZLJu9hKcbNn RCJVn/sOz0oxvJ6WiJLwBdbgDl6ozmJpdK+fxMErsz3RTFD/HOQCXSdirlvo6eGOg0M2 uUfXaR2QD8plRFGxLtM5wbh3MqF3+GTW8+wvVlrT0W/wSJyQtZQC2EAgaMeF/2v+UDBd gZDHXjUyH3OxMdisXvZ4NaxuvWTeQQ8mmwBkBqi2SOoj2sr6tiIYuVX0rD+CDFpaoM52 I4lkZ2qao3UIIi2ftK05h8EiG8o1S8kXRYMoNsaLub/VN5/7N2gWbArWjVaKMM6UTfmX mPQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070740; x=1735675540; 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=oEBb6lgw9CBGrH+fdl+vxQW2dmf3GxJ+EO5jjQIVvNE=; b=PuhKCgrR+Egiwdqbb8b5RfYiVjr/3VXTz8sItUNfbgnoECvIiMidFz8YGbD66ivrXE gSWUKlxGYEnmYyC/Gg4ybIuXdsKdyQc+GYTa1DR+N2Xz5mZdZwCQMze5d5W6Pisn7535 9tm+lOVEzLBlUVV+svb/rqrBwPqZVQKoyw3XmDE0O2U/O7pagNgFOQzCrzC3E6truD+n 9KLfYytU16SK5pxY/LawkjOyhL4hQeCh3NNakoZK3+xZxPxTW+EloDvSbqrEvxlsk9g0 PmgMn/gHpJtaVZkYLlOJMiCP+XOnsWVY6rV5xNxqod8Qw6KMtqZ0h5IuiSR8lDGJuK9B iyeg== X-Gm-Message-State: AOJu0YwNNroz7YwjH8OPF+1eRqH3IoEausAKnsK3qJZaMv8k0InYgwIr Q3BzvJJ3mDAtvo28WlovSJf3dDI/Lkqi3+4RjHPuAaaLbTLvHmdadSmhxiz0C9u4+7nltMUDEnM aYH4= X-Gm-Gg: ASbGncvjgO9JpVlHSenpj/tn/47mBGjWQUjjya24h/cuCQ+3hXX6J9swghLAOk6eyQz sKeum85r8YAh1kV8OaXjmRZZb5oCU7w8MmdHah58SJACzEZ3il9yukakD5FzP240xeKZRJVcnV2 d0undYnF1zHSUKHC9H7n1pHHnpXekAU/90U08zQ/bn6NXNScRmLIZcK+Ohq263lFLgy0NHsyNg8 ej+wOBd0DiLgbLSpnbXKFqe2YSBLO/Iis/gL7dbrbUHnQevBCA7dF1w4qOZKdWHMEQxZEpMav7F lM3GJarVNuisC0C139to6Dij5w== X-Google-Smtp-Source: AGHT+IF769/wLqaT8oKggrRZotE5VDbVp5899g+acCjZ5TvoJ+07ohFpmDt42KG1Y1rhlF3DO6ar8w== X-Received: by 2002:aa7:8d15:0:b0:72a:83ec:b1cb with SMTP id d2e1a72fcca58-72aa98f5b53mr29949932b3a.0.1735070740507; Tue, 24 Dec 2024 12:05:40 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 19/72] tcg/optimize: Use finish_folding in fold_dup, fold_dup2 Date: Tue, 24 Dec 2024 12:04:28 -0800 Message-ID: <20241224200521.310066-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index a68221a027..803bceb4bd 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1698,7 +1698,7 @@ static bool fold_dup(OptContext *ctx, TCGOp *op) t = dup_const(TCGOP_VECE(op), t); return tcg_opt_gen_movi(ctx, op, op->args[0], t); } - return false; + return finish_folding(ctx, op); } static bool fold_dup2(OptContext *ctx, TCGOp *op) @@ -1713,7 +1713,7 @@ static bool fold_dup2(OptContext *ctx, TCGOp *op) op->opc = INDEX_op_dup_vec; TCGOP_VECE(op) = MO_32; } - return false; + return finish_folding(ctx, op); } static bool fold_eqv(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D214E77188 for ; Tue, 24 Dec 2024 20:07:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAn-0003mT-Pp; Tue, 24 Dec 2024 15:06:34 -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 1tQBA3-0002om-2Y for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:47 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQB9z-0002Zs-PA for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:46 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-216728b1836so49402085ad.0 for ; Tue, 24 Dec 2024 12:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070741; x=1735675541; 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=dMXDaMRpMuM4NGt0K+4xH1eKpmwbvk+xmZf9n7LcDNI=; b=DmcC6s+gp6hiqc+SjBCQ1eCNGXcm93q8HWQzPcL1mtm5+eO3A80eU6I+PJQVtTC7sj hpnXyf8iKTZHyBzKdf7Du2smVrtx4Ac2/U6mKyV4uhpLJONjbdeEnm7IvbftoVMLuZ7b bFvYnIYR5LvvhqOA21wfod+c17FgFk9izybnCz7HytBpRFTiHxyOV9693A045jJAdMHM GzOM5Ufomj7UQQZ5lIytpZKVZPi6bGbhvwkeIvFS6v4vwMpB+hGGeWHDDc2Okn3Ja9i7 yqq6XnE46Tbm4RUqC+85gnujWHccH3StbvChMgAsEd4Kvub+X+KtZtCkMz+t7bluDnvh X5DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070741; x=1735675541; 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=dMXDaMRpMuM4NGt0K+4xH1eKpmwbvk+xmZf9n7LcDNI=; b=Gx7aH//Wi9jnJsI4wcSc8MHNJngg/K75QorTB9ft7qCkMoXirBVe8FekvDikU491Wi zQ3tuusbKZhI+LB4SOBGQ6u2L2z9vCUW950ulYImto0p7PIBHEvN7HqFMj0R2rCIF83V 2O2w8BPkY71ggWbY+dnSBtHozng0kRz/twqQMQWMGTlNM6ijasUCjhaMzqXIbcmeo7XH eXs3mDo9h5iuB78VFs7gxXOQRPuuvbTko2bwewe5E1GVODCeUZKaY5F61AQvdUmBwvrM WlcMDve4JNMlHvmkc5KSPi6ENfqNA++NJVH1Q4TkfYaD01JjWbdgVRZG7adZ4Jqgu9Gt uTqg== X-Gm-Message-State: AOJu0YyqQyc0+1BNMb8iGR3uTmXyy9FGKgsKR4rsnsoaeHTWa1P0Al/M 9wMoU7Z+ukadtdIJczW36dqe+bC1x7JsypaVBtL6OOb/2y0FDe8ci1eF1vVCR9aXFzlZ3liLubX Kwj0= X-Gm-Gg: ASbGnctVqf30MBpkU2VzgbY3wo5e9PZ3BsdD0BtwJYNiMb21d3aEge25kMwdt+ZseeJ rObS3DruAMcXwZYtjXRj5IHfVFj/Y+jXv9ipFqdrz6epu8AgynmbOvCCcHbYoaowy7dh9quCDBg KV2fLWUWs3+W04nwjxQit8eexs+nLZz9SG5lgg4RzFdcGEKAH1p3c8JfxJcdl+uHnHhBBvkPd2j hIYvgACInHX5mj2bMg/IyV2Xw1lL/+WXHy3hGghmzcDl0YyVmsGNYPMk4Ir6jHfp/SweXk0PMFS MZSHApzYIxPltBUyS4aKKlCjEQ== X-Google-Smtp-Source: AGHT+IEOK4VkFKE+QqV4RsVqkW2qXui7w+8ney6fBdZGAhb49CXGjVgS1CyLq14iWMfHxgVn1AV0Lw== X-Received: by 2002:a05:6a00:240f:b0:728:e40d:c5fc with SMTP id d2e1a72fcca58-72abdeb6267mr19386465b3a.22.1735070741555; Tue, 24 Dec 2024 12:05:41 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 20/72] tcg/optimize: Use fold_masks_s in fold_eqv Date: Tue, 24 Dec 2024 12:04:29 -0800 Message-ID: <20241224200521.310066-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add fold_masks_s as a trivial wrapper around fold_masks_zs. Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 803bceb4bd..f948cc48c9 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1072,6 +1072,11 @@ static bool fold_masks_z(OptContext *ctx, TCGOp *op, uint64_t z_mask) return fold_masks_zs(ctx, op, z_mask, 0); } +static bool fold_masks_s(OptContext *ctx, TCGOp *op, uint64_t s_mask) +{ + return fold_masks_zs(ctx, op, -1, s_mask); +} + static bool fold_masks(OptContext *ctx, TCGOp *op) { return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask); @@ -1718,15 +1723,17 @@ static bool fold_dup2(OptContext *ctx, TCGOp *op) static bool fold_eqv(OptContext *ctx, TCGOp *op) { + uint64_t s_mask; + if (fold_const2_commutative(ctx, op) || fold_xi_to_x(ctx, op, -1) || fold_xi_to_not(ctx, op, 0)) { return true; } - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; - return false; + s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; + return fold_masks_s(ctx, op, s_mask); } static bool fold_extract(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81779E7718E for ; Tue, 24 Dec 2024 20:07:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAb-0003YU-LW; Tue, 24 Dec 2024 15:06:21 -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 1tQBA3-0002ok-1T for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:47 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA0-0002a0-S6 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:46 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-216426b0865so55668565ad.0 for ; Tue, 24 Dec 2024 12:05:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070742; x=1735675542; 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=QpM1VqzEizRAO5S933D2pTQEw1V6cPopLqjkgjzXZkM=; b=YEBRN/AlCXpPLkL6xDfw2zQmd/eSk+cbYpFBLQt68HcmYAW7dP04ozrawc/0Xqo8nl 7WWZdo4/n4stHTQdApxOxvVXJtvvU3i0o55Io/Odz4iAbuLSvqi9akvd/9rZVgsiqFMh xx/t7Upd3Li0HnDbGgt/Yhkr8yE80jL5zq518mfZWPKlKUdUQ/QP6S29/3eciL4Z9HMV Vv+YR0rtbzX0gToIcvjDmYu/O+qKdft21D7BFuNVnf9lGrlKksByBW9Ird8Dqafe4Vfw 0p5sWpsXocmPTaso3Ambt2xQwqGS2ZI4affDNY97lap/DgGfDK5g2dE/I05ihllnlC4u 0jLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070742; x=1735675542; 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=QpM1VqzEizRAO5S933D2pTQEw1V6cPopLqjkgjzXZkM=; b=pV/P1Vmwxq31kO1wB3zTZEyYHW/enG63jzvlJXUjexzeZVGO319v0wj4Zf3nAw4mCb gQQN3Qt8ezfBMQvEgGafafkjKiNuBOspQePAwTePRckb7Tv++qef1qbyFLIdRThPUrpm iX/UYAsSzJ3xqRIHysv5PS4wcPS+5Z5beucUyTcwkECZL43XNW6Mp8R5nO2XfqWtYCK7 FnMjmSnFgyjV8N4APEYJVywMW5WpQOs0toDZc19BM3fdwJPPxQjHQ9JvkuAWY0et+mDm GiSXkEpogbrgLwJuvw5V8FgBDh0NcXwEe4JfANWngWoalD0Zoi6BFkWbK+M8ggVLwP5V ka3w== X-Gm-Message-State: AOJu0YxlOwEuJEPA24ZrWOyeNOa+4pI1ojSS7hky86gC+ysgVEXBTm2y zqPHHCsg4b3fyXQ9Otm5DnHc6M2nUdd/flnXnpFYje1OQzLp5f6ozcQ5vvUnYZhJBkt/JD3b2Us PC7E= X-Gm-Gg: ASbGnctTUJ2OhzFUGHDO44T6osXLqf5y+Gf0LptPSZiKnO7G6RpRc+cpJJ+u0xwERjv PhN3fGY4KnDP+XEW868tbz6z8UUjLeUsxesc0fZsZGvT/rCfE2HQ4BzPRCE66mFc7V7xBKLtYc4 fc2INMv9syA+LKg9vTTSYr/G3AnL6UYUZmIBHiPCcvQG/F0Gt/KnCZwisAdsxZACMjZTY3TThBc YocoxvyCW+uSBwJsZZqb2aHP3vSRsUymJNcFN0rlF0JHP2B0r+I0oYvAAKIYsdA5O0kuJDBGC0X RR+QVcznNjHfrAmNDpn6ioDzIg== X-Google-Smtp-Source: AGHT+IGxtQETXxvCEhak7u4e50AcxRPQmV/GhVfvDbQ1BL5UhxDex2XjxJ5ab5ZC6UKMGnVUao0H/Q== X-Received: by 2002:a05:6a00:4ac5:b0:725:f18a:da52 with SMTP id d2e1a72fcca58-72abdd3c1d4mr27143519b3a.4.1735070742443; Tue, 24 Dec 2024 12:05:42 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 21/72] tcg/optimize: Use fold_masks_z in fold_extract Date: Tue, 24 Dec 2024 12:04:30 -0800 Message-ID: <20241224200521.310066-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index f948cc48c9..8111c120af 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1739,25 +1739,22 @@ static bool fold_eqv(OptContext *ctx, TCGOp *op) static bool fold_extract(OptContext *ctx, TCGOp *op) { uint64_t z_mask_old, z_mask; + TempOptInfo *t1 = arg_info(op->args[1]); int pos = op->args[2]; int len = op->args[3]; - if (arg_is_const(op->args[1])) { - uint64_t t; - - t = arg_info(op->args[1])->val; - t = extract64(t, pos, len); - return tcg_opt_gen_movi(ctx, op, op->args[0], t); + if (ti_is_const(t1)) { + return tcg_opt_gen_movi(ctx, op, op->args[0], + extract64(ti_const_val(t1), pos, len)); } - z_mask_old = arg_info(op->args[1])->z_mask; + z_mask_old = t1->z_mask; z_mask = extract64(z_mask_old, pos, len); if (pos == 0 && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) { return true; } - ctx->z_mask = z_mask; - return fold_masks(ctx, op); + return fold_masks_z(ctx, op, z_mask); } static bool fold_extract2(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD514E77188 for ; Tue, 24 Dec 2024 20:15:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAu-0003x9-Ur; Tue, 24 Dec 2024 15:06:42 -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 1tQBA3-0002oy-HY for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:48 -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 1tQBA0-0002a7-SH for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:47 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21654fdd5daso55264825ad.1 for ; Tue, 24 Dec 2024 12:05:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070743; x=1735675543; 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=nPKsdrymAAbkS1XKYSlzg/E9Iz2RPvK/Ig74oqbHXos=; b=KtDNWgXBIbfNnxpSO+WVubHDXDaq82UBn5/iqJzo2oF5j1HYgsgqfI7PNnOCkvYd/r 5i1zMqVjzPN6v9mKfheacMqR9ZKvlWoXgjqhXMLgH36M8VGbibYlFtRujAV9+u0Wm4LW eRInWLyEm2ifgWK7A04DkSU3JENgp+yq2a8n3ryb3X2bmurIE4k0cyydy8xVEltfgYQM sqI1I2iPcxonIeop6BS+9unXfef48x04AgVF4cQ+fJMjmrQyRn0hzsnuI2tLRQprTkTc r1hZ8ZwGpFutPnKSxbb10EYJX/AkNRicC8I8E79FdZ7N2aGQN4g/ArvCUsjc7o0EBb1s 5Vvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070743; x=1735675543; 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=nPKsdrymAAbkS1XKYSlzg/E9Iz2RPvK/Ig74oqbHXos=; b=cBwseDxNDu8gm6yepwd1GIaZg2MYPr53M93twH1sCKWtbexPcXUo7V4kS1CoYl4jYq 5yV+biS4VaRlA4zNfN+Y4BW759uzEtjlsbtO3esUn6ebZF5dBZku4aBxnhHr1u8G7Vl9 v9nYlfMfOe7yrPD3jtTPmyP42wpY453QKtrLjoxZC12s3PHGdZxnNDiJa4VqSX2qA3W1 IGWSZw76YnuknnTutrrn2xy5+ZJNtQmUvdYoIlIj9xXd3LLrAVWd8bJefrGFIQXnvgoE 7GbF4vOPM+bHhPjglBkD/RtCXNLF6fdvTz8rS4LRfXb5CqcRFnPZWV+AipNyMdrse6Nv ooiw== X-Gm-Message-State: AOJu0Yxm6Iq0rf7nu8iDE6egM7+r7MDOBunBVD6/byCa31IVrZngbM/T KC27jAeo5U6xNmULBJ1lNZidHyl+bbYIpq8wzV+0Zh0qtpOl63DsCuhSKxc+igCcvve5wAHWKkT npKs= X-Gm-Gg: ASbGncsavEErd9bPSzOcYjpJ4MmYATwSbz0wxtJAR6/h+prDKKvQOfRt6MBwrJKDQPL cwQRTwfFk3vWrlijBiPjtv8ln5rkTSQgjy32kuLHsnUdwzefhghjzyGir0Uid1iI2udI4jjKge8 zh9IS13derva8ByTGmn3Sk6/AJFxLRtRSuRLPHArAH/CHL/c2QpN4uFZZmF8vImUGNKYoktm2KX O6ITeK63ZFMLwngs1ekIY04X1efULdDEaJUjkFrCwpBoiG6KUO6+FVA2CgCEMyHPkeU15VFq2rL PE4qC9UQuX+0yJyugJKUHDnqkQ== X-Google-Smtp-Source: AGHT+IErVbyki5W6GzBGG/WE2+PDzd+Gk6d+Q5AmQ2rUW14Tyi7PnnSN4IASIFQGacfsSkR796xlSg== X-Received: by 2002:a05:6a20:2d07:b0:1e1:b44f:cff1 with SMTP id adf61e73a8af0-1e5e07f9c06mr25390234637.33.1735070743264; Tue, 24 Dec 2024 12:05:43 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 22/72] tcg/optimize: Use finish_folding in fold_extract2 Date: Tue, 24 Dec 2024 12:04:31 -0800 Message-ID: <20241224200521.310066-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 8111c120af..04ec6fdcef 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1773,7 +1773,7 @@ static bool fold_extract2(OptContext *ctx, TCGOp *op) } return tcg_opt_gen_movi(ctx, op, op->args[0], v1 | v2); } - return false; + return finish_folding(ctx, op); } static bool fold_exts(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7886CE77188 for ; Tue, 24 Dec 2024 20:11:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAy-0004Hp-MU; Tue, 24 Dec 2024 15:06:44 -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 1tQBA4-0002pB-BB for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:48 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA2-0002aJ-Q2 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:48 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-216401de828so54802625ad.3 for ; Tue, 24 Dec 2024 12:05:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070744; x=1735675544; 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=K74UPQ6ATO0nDrlE7cqFEozEZk33xGq1bz1J9EIx6SI=; b=pBZJ9KiB9yKcGMNwZqXl4IEVdV8klzUCp7NRGl4Q+ee6uEFp3l617IL+KSJbzLX35T X3f8uei0ALu6yNTeztUMxIG3JPjdre4LuNEY9P9NBxaHOOMdXqGIHDx7OnWwpasfzAfQ 5kKQ2m0gGDSf90wT5hwpi0e8mNq4mmUfweFe1yzNYfCkVlK7Yf7Uucp6n99CFkTHr48o 4svWZD4K180ZyqOYhvgCo5BVaeM0woMTo95DB8iVNeC1uVTdOm6FPvTsk0z6qmClpexd uwOwCVKdmGdXMAClbyomq/FMzWJBoyAbT6SVKKgKXdDU1wqBntLTP249Pb+TDGySy0vd MLvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070744; x=1735675544; 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=K74UPQ6ATO0nDrlE7cqFEozEZk33xGq1bz1J9EIx6SI=; b=qzY3mchwZnsY0Bsp7cnrnKe2cfOiFhCt3dilznvmErlZ+eTTJFjxGQ483FhvrjI/F+ gFPjzTpUS9EcryRDMSq7H/754YirjmUqyBmi1YDFAQ6ixaFOLsdvwI4K0vksAMbRJes4 lferGBBYLk7RZlAQjL1cKX0fwJu+qFI9Zibyb240FsMbDe4CHBwggPzYNYXmrf+7cfNF fiz1mkkwN7EHYomvZYIKVBmoykbUTqtg68ysWTEYLb3Ni4MA0iLX9wA3ICW5n9+rmyeP Vugg69WT8lq2aWKaqN7L6yhY9dPHL4uEOfK27GZI+HEtBZFNTNRlm0eO0Zoxsb5iYsXZ mvSA== X-Gm-Message-State: AOJu0Yy3FEbtNNw6imzfE3yV6cvaorxp+QKGq+KmpJxw4VTM2l1zSzg1 mu1mrVs4XjUOJTr2Esj+bVOT5UWHDpMFgio4z77iDELDo2SK/8taS7NdknAzhx8MHbmvo0aguC7 RlgI= X-Gm-Gg: ASbGncvQZ7mVBglBtAmb8C/WyJ68zCAbVrDj4LaxeRe01lXXWfv7mjabTeAsVkr97xI fqWHHFdYR3T52HZi8msz58fQVIL7SDBOtuRU+RMY0Q9HtMmSezAer1jZppLfIclH2l+QBcyxQcy +K1zUkKCeNpG+Rghf7VqHrEI0ZKqfcBrPnzYF++AJJ0XDs8N0oi5YM50GdyslNeR/4XUgqtjXSh pWCCS2vh3VzEGo5f3bL7ECf9t5++HiSbwKd0i18JOlAhC7heKzsxKW20I9vwo+FdsTAWMqq9tJx q3SdBY00ekn9ZtYHzIMbvAMw5w== X-Google-Smtp-Source: AGHT+IHovg5eGdtTp4h4tD5mpyB8hf0d7yLpFQmYey+YNWla3BlzxP2UyV09RoLHJbPNngCU5aSDig== X-Received: by 2002:a05:6a00:414a:b0:725:96b1:d217 with SMTP id d2e1a72fcca58-72abdd7e0e5mr21657386b3a.9.1735070744223; Tue, 24 Dec 2024 12:05:44 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 23/72] tcg/optimize: Use fold_masks_zs in fold_exts Date: Tue, 24 Dec 2024 12:04:32 -0800 Message-ID: <20241224200521.310066-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Explicitly sign-extend z_mask instead of doing that manually. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 04ec6fdcef..3aafe039ed 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1778,49 +1778,44 @@ static bool fold_extract2(OptContext *ctx, TCGOp *op) static bool fold_exts(OptContext *ctx, TCGOp *op) { - uint64_t s_mask_old, s_mask, z_mask, sign; + uint64_t s_mask_old, s_mask, z_mask; bool type_change = false; + TempOptInfo *t1; if (fold_const1(ctx, op)) { return true; } - z_mask = arg_info(op->args[1])->z_mask; - s_mask = arg_info(op->args[1])->s_mask; + t1 = arg_info(op->args[1]); + z_mask = t1->z_mask; + s_mask = t1->s_mask; s_mask_old = s_mask; switch (op->opc) { CASE_OP_32_64(ext8s): - sign = INT8_MIN; - z_mask = (uint8_t)z_mask; + s_mask |= INT8_MIN; + z_mask = (int8_t)z_mask; break; CASE_OP_32_64(ext16s): - sign = INT16_MIN; - z_mask = (uint16_t)z_mask; + s_mask |= INT16_MIN; + z_mask = (int16_t)z_mask; break; case INDEX_op_ext_i32_i64: type_change = true; QEMU_FALLTHROUGH; case INDEX_op_ext32s_i64: - sign = INT32_MIN; - z_mask = (uint32_t)z_mask; + s_mask |= INT32_MIN; + z_mask = (int32_t)z_mask; break; default: g_assert_not_reached(); } - if (z_mask & sign) { - z_mask |= sign; - } - s_mask |= sign << 1; - - ctx->z_mask = z_mask; - ctx->s_mask = s_mask; if (0 && !type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true; } - return fold_masks(ctx, op); + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_extu(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 260EAE77188 for ; Tue, 24 Dec 2024 20:08:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAb-0003Xd-6r; Tue, 24 Dec 2024 15:06:21 -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 1tQBA4-0002pA-Aq for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:48 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA2-0002aR-QI for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:48 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-21644aca3a0so65832075ad.3 for ; Tue, 24 Dec 2024 12:05:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070745; x=1735675545; 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=k8tsF+Zaln0GqZenAMtz/m3flCsE/XhQzYQ3qzfdH28=; b=bKaTgyP7Uf1ixVkraHVLVwoDQadqXJJMeULt8uw9PwsoU01ysFu67Tbxo9wcZZ4+o9 lmBXCNMav8qy8PhuAw62nmRZWKQ9Cud+4hTz7RMKznRHGaldsWV1X4P3OvOR25+3Idlt PH9CYFKeyuoffwYMyH0TcUB1MOUI+R/dUzthSoX8Qg9FVzLUfQkTUyVtbqzX/sReaQyM aDHqOMLq5hWFQ5dfWvNSoTQbxzyyj8qaPx8e9viRftlTe+oxNxPtQHR8vwArUFOB79Wa tIYvf4YU+60XqjFLZvuM9PR+rRBn4K9iK0QiZPolRYt1d8D1foOh+4pzr63eP4YjfTEd kcPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070745; x=1735675545; 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=k8tsF+Zaln0GqZenAMtz/m3flCsE/XhQzYQ3qzfdH28=; b=T/siqLufsk0JvaEqLR/tNGC82pbbOHu//Jz5gHt0eIAbEZt+dypEEI50UgYpyZVVzT zZ/rEKI5iAjBhmyEB4HwwxcJUakWYvvTlZj2YqgQ7x8Soz3hRq6fJ4EGoezBH9DKsmzL DqnuGDoOuQ8vXFP2rBV5n1GDm8Ez3IBIgid+klYVVtA2Gx5/GyzUWkLLeIOxKxyCSYDW 9yJBjELQJUiMplZtySAeE0OAYthw+OUa7oDD+kWFhogZaBwSPH7HeXUlDP4+s6a/S1/B gZK571yHdyrmpObkmMlu6zozPtS914OEWKr1BRFMRDotTYjGbnrpkQj7jOusiEv4rYbc octg== X-Gm-Message-State: AOJu0Yw2KLNwgJERO5bSc/1oHqTMumiQyXOi2jkUnJ8eM3Y/uLbLx9DG K0uqn7H1MDoF6oH3Gk6CXsh4uLAF2ACWAW58rATp7LAA/h/2t4UBsYITrtTCWk0C9LVnL8t5F48 n708= X-Gm-Gg: ASbGncvUDHhZxYS2orJ4QxjXLTvE+HsV1pgcHRgr0LCfBySCmNV6QzQtnvBE6TVBWZI j5fz5FFmJmKEVKut4cM7oufsS0BoFcxodx11812qvc0S7aL/+yl6XEZWcDwkJ82c/LqQr2LpfEm N0gx0xMf0ha3plDP7ie4Dajc0z9W7/y1iu8i37dMZwT0MdNFbc3d7cm2zyb8pIX8gNA3hN88/HU ZBlziKRU01LX5B4UBykeIcplxs8aN5ZJSxc+RDMS4zBL5u/QUlNWkd0LY/HizCDG+OK+SFEMVa0 oHPIGRMvHjHYPZd/1BOW5WPKAA== X-Google-Smtp-Source: AGHT+IHlJrd/7c25mNQYyrwtlCGAtU/XPAdhnUKobxMH8nHdJPuho4gFdGqVctpk/PelbnvULrcJyA== X-Received: by 2002:a05:6a21:2d05:b0:1e1:a647:8a54 with SMTP id adf61e73a8af0-1e5e05ac4cbmr28870806637.20.1735070745152; Tue, 24 Dec 2024 12:05:45 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 24/72] tcg/optimize: Use fold_masks_z in fold_extu Date: Tue, 24 Dec 2024 12:04:33 -0800 Message-ID: <20241224200521.310066-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 3aafe039ed..f62e7adfe1 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1851,11 +1851,11 @@ static bool fold_extu(OptContext *ctx, TCGOp *op) g_assert_not_reached(); } - ctx->z_mask = z_mask; if (!type_change && fold_affected_mask(ctx, op, z_mask_old ^ z_mask)) { return true; } - return fold_masks(ctx, op); + + return fold_masks_z(ctx, op, z_mask); } static bool fold_mb(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6EC5E77188 for ; Tue, 24 Dec 2024 20:06:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAI-00033L-Gi; Tue, 24 Dec 2024 15:06:02 -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 1tQBA5-0002pt-If for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:51 -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 1tQBA3-0002aY-C7 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:49 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21670dce0a7so73888595ad.1 for ; Tue, 24 Dec 2024 12:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070746; x=1735675546; 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=MFhNaTorOWcHDFv/B5ASCBB74fNXcu/plUbi038NaCk=; b=j4tSOPVV+oTkrDAZ2wkTvij8JL3aoam2F0OcLOEEVmlUN5rGTHci0u/5rm2usrLfbc BqOJ/jJoULvNYcA/tGZuTuoFun+tME1L+JcYCgIC1rAUoQ4DubhQa5+yRhDQ8GMUjsnF yu3cnSjPKoMWXS78uLK6JHgtB+MNL9ow4Vf3FXDE6QZPDiFySpiuGc3egYfxYeQZiFSz q89ws4nAGmV/FpGH17P6tlkaOrnVF9x0OrLM30MJvpQhusPDvrIznAcABpLWLz75UObE OAKkk0jP2weDXRbGs6j+MxD0vVoLXe8TTlToRvuCytquSrNLk98CfpiqJaS2jrMLnAjT O78g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070746; x=1735675546; 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=MFhNaTorOWcHDFv/B5ASCBB74fNXcu/plUbi038NaCk=; b=wMuOcVtZ0a/QxvN3DxBTeEAJqlDKCMUwV6gelFaYSYU72HqVxt4WJL5n+AxhOXK1Ik R5p79MEVA64TDnVf5vccAZ6KjAi1vvo67LXkehkpmJYX5EhUvqrDIt7HMOONBbIkrUVh Xp4oSbDPJ4JFN6i42PCA8OFjYl4NMVxNrqJmtQrDU7jNUAJQc9uu13QXYLxwYsu9HZVp tdl6/KAnj65rZbVDrJIS/WKn8m+XnPfgTzzV7XlqW1XdABQTqcxZbU/r3TuhKpnkiA9E ZAX1Qztzb2MqU0HGc5ni0AGmJ7ZVOXXRG16VtIYe/0mB9azz3jry/bPd4k/kXs2CNEaO ibow== X-Gm-Message-State: AOJu0Yx8IfHxBU1fnmiGsKgCVB1zvVgKwq2eG+AYEHYGNnIUEPlpvK7y 8y35wcqtj9C2Pj6rGG/Y7l9bA2g/UsPl0Oq2pMM17Rd7dz4GTO7DAA+i3lG9/4te/ub/BDsbHcI kocA= X-Gm-Gg: ASbGncvyemmWPZyy9dQvICRsNyB66TzU/pkAf4LAdlGVvOlyGuyeWbbXas3K67rlerJ 9GrHqcIPIxKyPjZbccpInXbdqEZHzQbEU1UYQj5hzUoHeCBAgNoq1ITgUsnjYEIWtTInJn9dHFC ApGaKcQWt53zYsJ9MtCYdvKMe6jcGDp427zLx6aPErd+WeZfYJQzj21PO4Yb5eodK8b8OPGiQgu 7tn7TY2zrocv04kqgSstMcHkmEaP2qQPbU2hvfx5EbDdg+lStHzrQUFBd8Od/hZkjayKQjSA1is AI+92aD9yRN3JeSM8JvZ+OC/ZA== X-Google-Smtp-Source: AGHT+IG1BqmYE1D0LDJDZazW7vpgIbbcfBkLWAH0N1uOLBiyMV1W+izHUY3ZF8is/QKqM2ErxkNcJQ== X-Received: by 2002:a05:6a21:9017:b0:1e1:a434:2964 with SMTP id adf61e73a8af0-1e5e0459369mr26829413637.2.1735070746221; Tue, 24 Dec 2024 12:05:46 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 25/72] tcg/optimize: Use fold_masks_zs in fold_movcond Date: Tue, 24 Dec 2024 12:04:34 -0800 Message-ID: <20241224200521.310066-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index f62e7adfe1..0104582b3a 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1889,6 +1889,8 @@ static bool fold_mov(OptContext *ctx, TCGOp *op) static bool fold_movcond(OptContext *ctx, TCGOp *op) { + uint64_t z_mask, s_mask; + TempOptInfo *tt, *ft; int i; /* If true and false values are the same, eliminate the cmp. */ @@ -1910,14 +1912,14 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]); } - ctx->z_mask = arg_info(op->args[3])->z_mask - | arg_info(op->args[4])->z_mask; - ctx->s_mask = arg_info(op->args[3])->s_mask - & arg_info(op->args[4])->s_mask; + tt = arg_info(op->args[3]); + ft = arg_info(op->args[4]); + z_mask = tt->z_mask | ft->z_mask; + s_mask = tt->s_mask & ft->s_mask; - if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) { - uint64_t tv = arg_info(op->args[3])->val; - uint64_t fv = arg_info(op->args[4])->val; + if (ti_is_const(tt) && ti_is_const(ft)) { + uint64_t tv = ti_const_val(tt); + uint64_t fv = ti_const_val(ft); TCGOpcode opc, negopc = 0; TCGCond cond = op->args[5]; @@ -1956,7 +1958,8 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) } } } - return false; + + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_mul(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DB99E7718D for ; Tue, 24 Dec 2024 20:08:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAT-0003Mm-KJ; Tue, 24 Dec 2024 15:06:13 -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 1tQBA5-0002pv-NF for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:51 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA4-0002as-9S for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:49 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-21631789fcdso46982955ad.1 for ; Tue, 24 Dec 2024 12:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070747; x=1735675547; 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=8faF0oSE8gzDQC6SYYBtFIF/07pdwecYEYpdE3G9skM=; b=KYw7HcC4uVKEqyhythEKIVNaVlby5crkZqqj5TY/qY+5khpcQsasQk4hAI3DBLo9rz ezHNhgGlnbnEOB7RPCkRc5Jpf9cTnIWj9FLaLl3s6SVndAlyXLkowpDiSOnA0aao8Ki3 SQMpWuIqjh8MR8ciIxjGWPv7/J8Ln2UCrhdXnIgXOHoiPU7vljH/U8/p9js+ZdBm7lO0 DI89uOJA0huyivYIsJHyDE++BLhxXZ6mG8VXCA6TdrU600Kvu5z8aAvrLhKysAFCqg4g TXMTEhEOewyQy0jE56CjDpJSR1LOdQg8v1/eiyE7H+BmeXPOD/Q4Mf8aF5pb5flLmYZ9 JCgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070747; x=1735675547; 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=8faF0oSE8gzDQC6SYYBtFIF/07pdwecYEYpdE3G9skM=; b=fq79QT9AY/H98kv/WQn2dYEAuXLeXUJGLwKvdvLo17YYbyE7JpdRQRxUKfFde90Vcn vNoja9/ZNjOXjT23cKHsMqHucz6Y2SkrCieGh/yO3qDG6nP9wdqD2nOob7th6UFWqj5B pQJgvkuDWkv39FTJd7d54CeHNJs8gwVjVzjy9YT+9ohCqCeaQMBaIzTH27PwaRSA/y07 yYwDeOYQBapnKvb7G2H23g+PeyHD/R2sD4zPa4o56mE43CBKSK8l/eyFaEbSRJnoNbHl Zom2S9YTOmRTslHp+pJmBvvvZwLIo+1HPrnj4K8UhTic49IkewHWqyoWzVbcZJ8hhQIu KUIw== X-Gm-Message-State: AOJu0YwgSYdWAH7dV9CAEKFSuwg5zMDKf0T3EKOZnZdaYSG0ZSaT4IQ2 bEeuAeBiS9REWbgFPmSCkx/h17b0KsMmE/czDJKfcRzcI7Enp7mTB9Qx8Vdq3zRHZFYL9YAaPEO +hrA= X-Gm-Gg: ASbGncswRUiI3SC/bzGRNryVwRl8Ua6fO03EJltNDtR6AtiIc9x4DeZbC5jjY6oM2E/ 3UV5LBFWyXOMD64qSVzuoitKoS7608B+tbqI6G8QY1eeJcN+mWrm0LJSRzPfJCFSsuDlll70gzW +BFdOxc7GgxH31Gt9vYc0+0HZPQY5zZFztRDFdNOHXCoYOmjvu5JxStaX3+rdKodwqoIEBveJGq GfKcf1xG98N/Nq6VKsChr8XvpSmANOLwM5iYcasBwkajCmeNOxEJNfj26HkOIGmBN+gXA6iGJZe vAak9XVkF30ABgyPLCRy6gsj3Q== X-Google-Smtp-Source: AGHT+IG0VOzgkWI7aRvCq5mwIrcS1j+SH/Lmho8o3KLhpIreHLVw3YWJts5jLUXYUpcWnXn49KPw5A== X-Received: by 2002:a05:6a20:7484:b0:1e1:9dfb:2384 with SMTP id adf61e73a8af0-1e5c7001f32mr29900262637.22.1735070747065; Tue, 24 Dec 2024 12:05:47 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 26/72] tcg/optimize: Use finish_folding in fold_mul* Date: Tue, 24 Dec 2024 12:04:35 -0800 Message-ID: <20241224200521.310066-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 0104582b3a..10d1376f62 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1969,7 +1969,7 @@ static bool fold_mul(OptContext *ctx, TCGOp *op) fold_xi_to_x(ctx, op, 1)) { return true; } - return false; + return finish_folding(ctx, op); } static bool fold_mul_highpart(OptContext *ctx, TCGOp *op) @@ -1978,7 +1978,7 @@ static bool fold_mul_highpart(OptContext *ctx, TCGOp *op) fold_xi_to_i(ctx, op, 0)) { return true; } - return false; + return finish_folding(ctx, op); } static bool fold_multiply2(OptContext *ctx, TCGOp *op) @@ -2023,7 +2023,7 @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op) tcg_opt_gen_movi(ctx, op2, rh, h); return true; } - return false; + return finish_folding(ctx, op); } static bool fold_nand(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DB10E77188 for ; Tue, 24 Dec 2024 20:07:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAn-0003ly-QC; Tue, 24 Dec 2024 15:06:35 -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 1tQBA6-0002q1-Si for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:51 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA5-0002b8-8Q for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:50 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2161eb94cceso39841595ad.2 for ; Tue, 24 Dec 2024 12:05:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070748; x=1735675548; 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=wktipe244FoeFQSExHME3WY9VZ8Aio+GMnAonDh7r1s=; b=BnOro3oGB/Td4mAwGj0+5N29eIiGPm7Hudg9feDOWU4skGkuEX1SzDGrKD7pY1Fg0/ eRLqX+Bg8OMVStcLqn7kw9xlcRZOcc8bAH1Yy79EP9KIcd1bg1Z63PYADUHGm94PBuzS aUxqqDGyWKlMENtCt6OFxqzBvPMbU777fVPvhwq23pU/qZf8fHZnrqxT/i0mBZ7j4w2i +NdWe/rAssPvk2w5+ye9uP2vG33Rt1tPPMpGYs704fP7EKG89HPX3a6CgCZcwTTM5te3 dQvzcmJGFIR2BSWVessEHgnWiQlfd0Uc6unwXYSVPOycwPSM/2biabI+eQyXK/y7WpPb 0vLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070748; x=1735675548; 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=wktipe244FoeFQSExHME3WY9VZ8Aio+GMnAonDh7r1s=; b=YV9SdUR+wvs0nwa4yAPOwUw4MJOlBJVHFIDJapbZ0WoxJQuuiLpGfR8tSeU2Ihz39K Xd0U2DqmKDutFTPY5+qRY+wJiVW509Oo+qdtKoSnuTQOsVdDt+JpIqMGVOsX+/mDtA9K 54H2BjwT+HJfGqkj004ZMj26nEEUCl8frndy5DW41zlR/814DjOVxVrNewYMBKP+gG/e mFCYpgLMxhVg60+SjVKHjqqJiCUwCOkM8SUeRGmzDl+SSkUVPOY4GthXXp3oH+LiSRDf zkglCt/Nxm6NSJ2Zsu5bha4ZW5DlmziKSGSyQJGC0CR+3fM8YSKWPQlhTfCukQXHUzLU rwlQ== X-Gm-Message-State: AOJu0YwWVVke2Za1/eul70N2BTBcSfrhz0oD3mAnbIvHCp8vkgMueLCn xwll/Du7zh832q/BKhQbK7Ya/IVdPP6L5zFyLwqqwY5Y3IgQjAsFtQ7OHw1e+XDj08MfSp1CGbG hxG0= X-Gm-Gg: ASbGncv6JY7UzsyenMAOUrl3DgSXLcwZd47OKhQDkb3IreX4dCEwtKzUY4MH7RFJm0o 1Y7iBXs7hYZtVEliBlV0Gqdb1jTdlehYlyuGFVKW1DEAc24JnJL7Xbgv7kXHNtvcg+U74N7u0xy dYYKUK7M11Hq80IjLSU8RcF/ffBfaO73TAODdidsou4J1DOqfoi7HNLuUCucN2mw+Ur8hz68hUC lENcoCmRShsJkA/8UziexhHseeVHqXBWfKaZMhHDY0wqnQFWBBU+f9eSzk9hxukFMHs+EUJBzPs Qvc642himYfOMttYoAfBwhMx5g== X-Google-Smtp-Source: AGHT+IGk3vDEuFhD1Kxb4p6bO2w8WJ5BrQ9GNLjPd3/0tGPQeTj2NomanNDmvqvn0ZO04UdeQ4MC6Q== X-Received: by 2002:a05:6a00:cd6:b0:729:a31:892d with SMTP id d2e1a72fcca58-72abdd9603cmr28693846b3a.8.1735070747929; Tue, 24 Dec 2024 12:05:47 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 27/72] tcg/optimize: Use fold_masks_s in fold_nand Date: Tue, 24 Dec 2024 12:04:36 -0800 Message-ID: <20241224200521.310066-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 10d1376f62..7fe5bd6012 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2028,14 +2028,16 @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op) static bool fold_nand(OptContext *ctx, TCGOp *op) { + uint64_t s_mask; + if (fold_const2_commutative(ctx, op) || fold_xi_to_not(ctx, op, -1)) { return true; } - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; - return false; + s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; + return fold_masks_s(ctx, op, s_mask); } static bool fold_neg_no_const(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C15CE7718D for ; Tue, 24 Dec 2024 20:08:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAS-0003Hf-Rc; Tue, 24 Dec 2024 15:06:12 -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 1tQBA7-0002q3-Cu for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:52 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA5-0002bN-VG for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:51 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-216281bc30fso65719345ad.0 for ; Tue, 24 Dec 2024 12:05:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070749; x=1735675549; 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=lQGEeo180Fb11kHp4BmckzWOB9pBkkJv2EtGQzoK4ro=; b=ZH6XJrll+RXihC94LDnpleBZwZ3qCRiiBElFVLz1yVHpWZIHJ+iAkVQlcpyluGMKSM XBQvjWJJRCFGgZQ5fVLVPUUwhr2V/ML0cU6sPPSIH6ua/9oqZXEHH7KMGI5is2oJ0Uu2 tkspb14X2lyQ7texRD0frOlYXTj7UJBomfJkEroBfwvLCHeRjaWL/rBUnUtg8RZX4jcR ciADGLmJOXSkCqqT2EuKjQNFjJkbM+lNgysXtVXUoTX8sC2qIm5Kik1PjWZ3gtpZl43h wdK/8FDB2/0JXj6QR8H6DX1ZnXxvMEM2xC0DqBqRooeniaDNF2mS1diJO7IxPyTNdzMI GU1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070749; x=1735675549; 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=lQGEeo180Fb11kHp4BmckzWOB9pBkkJv2EtGQzoK4ro=; b=Z3O50nFOywAghfXsykNjJWsObsZ4YBIgNIMg8ko2qZ5esLDmdZX4mSJ6TR8vVuKOjW oIL5X9ftXSH9G9ob0L5yixI2DnxM7xa0LjhFpFULmqlxZqfFlAn6MAhdZD3QS4bqNT3q 783sHvKdsT9M+Uhs3qUyO9nfpEeKM8j6tJT8FC/folxO/7oNoEByaMJVt2Ukq0kjRKJv NQpIeuFRejJShq3sWqqpfJILyliXprEeHz0YdSvjEUr7XkF4Nlph70ntH77/gfw+eklH Bd+1UtDQ4at28PKzplFJuv90JSzEAYa+nNN7Lm0NKp+FQTVz3XnEfPzCm++/bVoM8W1v Ow/w== X-Gm-Message-State: AOJu0YwSta8Sf1DpkjYxxCzH8eK3B7/8ZHA8bhE/xVSNTtm5H/cpGZ7/ mV1ToDf3q/UmT4zxoIBIiEQovMGzQFDyx39hBAoTXbx8gU9aRCdamOZoBJY3PPKN8gw8WjiQbji bT10= X-Gm-Gg: ASbGncv1SaGEQzXoYpLlHlACn1eBMof14bBcdwrYxlMF3i+YdcsHwzGgl+DYYNIQkRp tl0Zzyd8MMhJOYCQH+lJJMVLcs/R0nZV9EykypDkXRSYJYDg26kJoCsHLMd13cfl+dVJ8BTaml/ 6ZMCcOzagqFhDSpMiUQslbHl/MKUlA2q8hlM+TRyXE3xteF8x9D846NM4pSWmYKnLPY2Rh+s/1f zhIj7J1BQe90WmUZftOUnqN7VQwC1aUWFsxDOG9l1ScCKkas6lS1fmQ66fum1whYUqLV3hjwa7n fhbCR5GjVJAWqLKa2Ups5tcZOw== X-Google-Smtp-Source: AGHT+IFPeoZpipi5ZuCoT9Rt2r+bXdkmgD028HYDIEqhHLjk78Kn9w78E0NrnpBsulejEa5Ga7yi5g== X-Received: by 2002:a05:6a20:1596:b0:1db:e0d7:675c with SMTP id adf61e73a8af0-1e5e045a0b9mr30610557637.13.1735070748808; Tue, 24 Dec 2024 12:05:48 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 28/72] tcg/optimize: Use fold_masks_z in fold_neg_no_const Date: Tue, 24 Dec 2024 12:04:37 -0800 Message-ID: <20241224200521.310066-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 7fe5bd6012..fbaaece152 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2044,14 +2044,9 @@ static bool fold_neg_no_const(OptContext *ctx, TCGOp *op) { /* Set to 1 all bits to the left of the rightmost. */ uint64_t z_mask = arg_info(op->args[1])->z_mask; - ctx->z_mask = -(z_mask & -z_mask); + z_mask = -(z_mask & -z_mask); - /* - * Because of fold_sub_to_neg, we want to always return true, - * via finish_folding. - */ - finish_folding(ctx, op); - return true; + return fold_masks_z(ctx, op, z_mask); } static bool fold_neg(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44A52E7718E for ; Tue, 24 Dec 2024 20:09:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAU-0003Nk-0o; Tue, 24 Dec 2024 15:06:14 -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 1tQBA8-0002q9-Dr for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:52 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA7-0002bb-07 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:52 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21670dce0a7so73889605ad.1 for ; Tue, 24 Dec 2024 12:05:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070750; x=1735675550; 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=m+KmIKK5m1+rAgUJimrheKhjHg0Yeug9PGMeGHHJk+c=; b=DxNMIBTsVmglyud2RYa5k0KvGaynqdLFy5i3nu2C3Cau+wcI+LgJ34k2nVQs3F7Iz7 OU2+KVNwcySRn5p6Yoj3U8DBpi1TcOuptWyG8UV0+uAKAZPr8+XUDeZwTsrLamFbmOLj JeZPVj7YYdSBiBvLHcrlIf1KYg50yKi5LNstCa07TFxSnJh62jkM8NywfBqpGm8ByZEr 6KY5b1Mspx+qAPNYfRWgpl1eHuWslC9zrpnQbXEo4OBXC+wLTdJER9G96Y3hRKkhchWd Nd3hky6HF7kcHxFak0U9JKzOQEXigSSdF5pQnw93iKaIdXs2cnCQ5wpGrXpEj3CjD5vj J2jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070750; x=1735675550; 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=m+KmIKK5m1+rAgUJimrheKhjHg0Yeug9PGMeGHHJk+c=; b=fTz1AXmxhgGYeyj3vKjdWnDFc+UJ3inJyQ8EV739DBgNm0m2FL5RNzkNNiYtBLdZQA Smzc6V3qUpAKTUkIp/QEG1BhEw3gPI7J65nztQHyDAzVE911i/Z4SoT0AefHPEYrwQpr 9RLz3lEFNglEZaq5xWU6m8ilxXw3luwxWZSOyZ7IX6EQYYvZ1NT9aDUeDSA/XKZ8W4ZC S4kILD58a9vdIYtGZTk+Sqz4YEKk3O89pMRYXLSKernyZRpYa7/9VMKu9ZCzM38vAHnJ bnVQQVUnFvYAGBBRF0nMxcA1UPzJKrNf2sPKcyHTTItbv2YFbejTrowH//SJUF9dDVOS BvKQ== X-Gm-Message-State: AOJu0Yw3NdLLwNagEKr/oe0qjaH685QOKfV1M8aEapFfGWTpA0gbvEas ss91WNi09NBbZHNd31KSEF8192CvZ07B5ajVxARIHhoJ5dkWyLh2pC+WyDlPZR/Vc8UB1Ct98UE 5EVY= X-Gm-Gg: ASbGncsoJS5+F75B5j3YW/KP7ZEpbTdL7RIupITN9VwVjNz9CMsRT3Xj4cDZ17Fu9gL PhAx+ADfMTUejpIWsAd3aFGrAEgHifJDQQ9029F2JEpAzRtWiyx54BV8wa1Wwn5atxfQp4eXHl8 6rRQDnFSK8wFjw28H8c66fHFMvxOHNWSIvTD39PwHZpBhX8A9oe06pzjdCyAnfRXuS+/M8wOwi5 WpJg1f2mfgsnkuRubw4S8lTemo7liZyQhy4hiOlp2nokaWV9KU7IxrN/cMrDRg1d/p+IsPCrFq1 S7xVHKeDAH4BykS0EmDlk4GkMA== X-Google-Smtp-Source: AGHT+IFRJWjepRfH7p438/NpbwKJARUYpzyzA2UsSXUSYVVCAj13FJJaz5SL/753jpJIAQ9o/HEWEQ== X-Received: by 2002:a05:6a00:8d8d:b0:725:e05a:c975 with SMTP id d2e1a72fcca58-72abdebc11dmr26292281b3a.19.1735070749726; Tue, 24 Dec 2024 12:05:49 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 29/72] tcg/optimize: Use fold_masks_s in fold_nor Date: Tue, 24 Dec 2024 12:04:38 -0800 Message-ID: <20241224200521.310066-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index fbaaece152..acff3985f3 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2056,14 +2056,16 @@ static bool fold_neg(OptContext *ctx, TCGOp *op) static bool fold_nor(OptContext *ctx, TCGOp *op) { + uint64_t s_mask; + if (fold_const2_commutative(ctx, op) || fold_xi_to_not(ctx, op, 0)) { return true; } - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; - return false; + s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; + return fold_masks_s(ctx, op, s_mask); } static bool fold_not(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D624BE7718E for ; Tue, 24 Dec 2024 20:08:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAw-0003yG-EI; Tue, 24 Dec 2024 15:06:42 -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 1tQBAA-0002rq-8Z for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:54 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA7-0002bq-Uv for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:53 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2166022c5caso50537755ad.2 for ; Tue, 24 Dec 2024 12:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070750; x=1735675550; 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=aEBTSGoKSzGGXaHrfubxIygx65LoU6vieRsyMgqBwp4=; b=lFcTcIBQJXQDmu+DRM8Dq/vAGqsOVTeVbv0Zhb8Uka8sudJIjgE5sDpGjUfy5Mh/pQ XwA82NceN6g4fBnncYlJeA7euIvjwSH9P5Ys1pVSELos5iA93LIDLN3j9igSzyGmBGkG rgnffitgNduvKe1J2XyDv8Ojc61bt5FFg7XZ5NRgyJ2UGUdCvtqm0rNMiidbbxG6Pt06 Zqm/Fvwn1cCJ6RkVBRN2zi/+0lFyj2pdX/KNNlB3UfzZgh7G0jBYuhysZTOXcSlxKCN7 SSZqtGeYcSXsbdFtw1THIPqf+svJArd4NknTuKBOlKWdUQ3czuO9d6/kbZLMUnAlE/e/ aCtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070750; x=1735675550; 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=aEBTSGoKSzGGXaHrfubxIygx65LoU6vieRsyMgqBwp4=; b=njzQPvXBJKq9aQQulckqunPEluRxWOZILhEu36rmOF8AFrRCdtrCvfwykouthqAey4 69GdM8CtymvOaykvdxp6kGJ4hXXOui0lcXeVRydES8SJEf+9tFgrbl2BUJkowpvcz8qg xRR215XOXCxy+VY1ewieustedXMam95vq+C3C72FWUM2/eQuJFZ08usyRi4TUyIclK8z EfnFY0ODMa+WfYFII32jiFmluZ7wWqKtXTsG/EEL0J7OW+lUMH4zQTFNPYZMCSuc4eBZ qkY86xj/Dxt2dW5uh73sIeH8km+r2YRhY+N8o9NGjBV9aglvFH7FAWZL1fyLigB9MWEn QFTQ== X-Gm-Message-State: AOJu0YypS5skf5xZBbvK7eHGo+PUpx8zoT3w6wDUj1fu/ZfzX9HtGdRh jT6M9fuL6m8iret4mRaJqP7Tme3pvk0Mptf7D1peNPEGqpgWoijE1M3UPIn0JR0DsyDugUUEVvt fHdE= X-Gm-Gg: ASbGnct/aBsdM01/op2KLr+rJm8iDvMcnpP1YQni97Rp7hJk3egczm5WwHJWzvQwNuk 7OiCjPvUjxaFBZHMmxmj9rOChmjbkJNdU+hwM2yKv2irUT0ylDhapRS1Ny/mnaTb5o/OMf/ileF crey4Sxb2ZcSN+uQS2NtIqzCOqZd65FPS3tt+eQ2ghKSalA7xZNR0PU0F9TTM4ZXgwHrUAgdtOG cSJJqUB8axjm4PvwXf7WR9seMrejYcYlc1RlvuO8Kex4MrGwhT2Q7CBA3rtY7u0n/6LJ8dygvPF sdIXqI41OiNcEwbRad8k/KevGA== X-Google-Smtp-Source: AGHT+IGc+d3IWpHXxky+T0bKz9oJ1Yyox6Kbhx/t6s26ucXtEpKV8muNXh9wlwmhabZbPvYEfgy1tA== X-Received: by 2002:a05:6a00:1702:b0:728:9d19:d2ea with SMTP id d2e1a72fcca58-72abddb2115mr26199908b3a.13.1735070750645; Tue, 24 Dec 2024 12:05:50 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 30/72] tcg/optimize: Use fold_masks_s in fold_not Date: Tue, 24 Dec 2024 12:04:39 -0800 Message-ID: <20241224200521.310066-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index acff3985f3..4ede218bfc 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2073,12 +2073,7 @@ static bool fold_not(OptContext *ctx, TCGOp *op) if (fold_const1(ctx, op)) { return true; } - - ctx->s_mask = arg_info(op->args[1])->s_mask; - - /* Because of fold_to_not, we want to always return true, via finish. */ - finish_folding(ctx, op); - return true; + return fold_masks_s(ctx, op, arg_info(op->args[1])->s_mask); } static bool fold_or(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19CF8E7718D for ; Tue, 24 Dec 2024 20:08:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAx-0004CX-Nr; Tue, 24 Dec 2024 15:06:43 -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 1tQBAB-0002u3-KW for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:56 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBA9-0002c1-Pz for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:55 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2162c0f6a39so64870885ad.0 for ; Tue, 24 Dec 2024 12:05:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070752; x=1735675552; 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=RorC+bNoeysLqpLQ03oC4wLhRH1BlwQyizXHc+0rwk8=; b=UIgayo6OoaZ0+wtR4EIj1hnV8r1YZ04K8KkVNP+rkzErNcB3Lf7WWEFyzUZYT1aFzb F5OdkE3ZmlT6Dv6ADlpdcmxarVsnsrYw871lGzD81bozwOkOfmYDBbfxVhc52R4k199A Ka88K02fo1FfcKg3TLLEqupf2jGb//IIpViwNWqEhHgxJ/oN1f8bUytrJIJ1CMRJbFNd MET1h4LsPIwjAM+HtI4WcbQxbQoDTNixRT5MZSnuMRoI+g/JBXIy9Zkek6OFEw+af2kS /goYHbB1Gr94KGjXrrGDJKg/cTe1Re3kJ+HLhW6YaXgR2sVqq+Mt+EzAJ+vlclNNH5oG h1VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070752; x=1735675552; 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=RorC+bNoeysLqpLQ03oC4wLhRH1BlwQyizXHc+0rwk8=; b=W/DQNwL13ChyhHAeiNjvUvEygSXsvE5oquyjCdrb+rdrIiO2sh4yxZ7Y1rmPm/9M1i ifkApQgFOo1iKhVXxYXYiKl5fGuJ4/tv3OBk1gl2YBvY5+w0C67QYEP91jGqm/1hjA4J VpyaiBGMTfIE2QP+rzgDT36VBhNOKIJIebw+1iRZ/Bq6HqffrfZunJw2dxUvGhIr4SbS IlgVOoD2+YRBgSm7vHOJhkqAwUSLXlrL0OZH6XGMfYUfDSOwT1ONFj1lwiwC+lXCo8FF IcjIjmGctgLQeg5kyU1RUFaxRASWCCZttFAXHkvAg34MJ0UFXiqS8cIMrkHp8c+o8EVs bOcw== X-Gm-Message-State: AOJu0YwMZiCe7q6YwTufzssDLm47qvC/4Fh7hsn6lPBrGQXvHZQx8LHZ Auw0Zwt/u+S2/6EdlcaJ3eGi8YijK9eBiVHLUEEgX8yAaKhz5e9FMA6Ea+P+YS6d0BkYuFXsrUl 7l0Y= X-Gm-Gg: ASbGncvspHigelU6DEmBpWyPeT2Syqxn7cvoDgcOVm3LtUKpQvVyEiEDLOoQ57ABANx J58Ig0X0nl1vuSH6eR1HvEPeOGUwQqMPChBrW+NKZZvi26+P4mcSkttlyuMp1GbvZVyfpTC9XvY ppIwnHCgBcNC9/dibsHrZ7t+d0VYZuXY0SmUei3XvCmSqnYdHwjGFm+NyiYMNSe+xXDrhp/mEC2 aORGzG/MiTCGbRysW3DMvJN35/Vurx0736qVpvJey4IRjxrO/wRn01DM2r6J1eGh/rVA0n2F7Jk Xb+6eBoiBNDzupdUZC0w2gqnSQ== X-Google-Smtp-Source: AGHT+IH6HFDZkcBFFL9TKKrQbGZOJ7SnizU0+LZpVQ7Ne8/QfKeAi3RwRsiwIZvYXEeENfTIF5DZ4g== X-Received: by 2002:a05:6a20:914d:b0:1e2:5c9:6831 with SMTP id adf61e73a8af0-1e5e1f57c6bmr24704790637.14.1735070751644; Tue, 24 Dec 2024 12:05:51 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 31/72] tcg/optimize: Use fold_masks_zs in fold_or Date: Tue, 24 Dec 2024 12:04:40 -0800 Message-ID: <20241224200521.310066-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 4ede218bfc..e284d79fb1 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2078,17 +2078,20 @@ static bool fold_not(OptContext *ctx, TCGOp *op) static bool fold_or(OptContext *ctx, TCGOp *op) { + uint64_t z_mask, s_mask; + TempOptInfo *t1, *t2; + if (fold_const2_commutative(ctx, op) || fold_xi_to_x(ctx, op, 0) || fold_xx_to_x(ctx, op)) { return true; } - ctx->z_mask = arg_info(op->args[1])->z_mask - | arg_info(op->args[2])->z_mask; - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; - return fold_masks(ctx, op); + t1 = arg_info(op->args[1]); + t2 = arg_info(op->args[2]); + z_mask = t1->z_mask | t2->z_mask; + s_mask = t1->s_mask & t2->s_mask; + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_orc(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D17EE77188 for ; Tue, 24 Dec 2024 20:08:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAb-0003YZ-Kx; Tue, 24 Dec 2024 15:06:21 -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 1tQBAB-0002u2-KW for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:56 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAA-0002ck-00 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:55 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-21680814d42so52214545ad.2 for ; Tue, 24 Dec 2024 12:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070752; x=1735675552; 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=9gMoFC5QlvVuVHKNivgLi3juCNFsVMGqn8yIw/qWmEY=; b=u+nEM5zQyp0opjAYM8ZpROoLeYAc/0Z3y1x7BItmYEeBW/dpOBd2jmjz2p5GfdVF30 7dkSFLMmFOndD6qzhOfvmiSddHd8Pt6umoQEPLj2LyI/wIUb0+dZbbQ+Q5AlsVVBiioL otTyToerjQcgB3ZmjBikYtJ23hNMDEp+3ybwTPS3lqKEUn5itXfQGwOp3g0zrowhkWwm dV+9pQ549U0qRZUTE7Yl/lZHXozxmIFTo0t1K8IjL3++ehqpRBoef66PI/MappFkAisI p9hGMIkaBtTvaoE66u4+2MqP/6qvuNkmQTWAMcOfSF1hyZRessa3redlVwDvtcbj0PJD XTKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070752; x=1735675552; 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=9gMoFC5QlvVuVHKNivgLi3juCNFsVMGqn8yIw/qWmEY=; b=xU75hziDRj8LjCpjCZkM/V1bO0Xe+lHCklqffIi+LEAaC+0iFOvSCbbF281yV8KbQg 0N1SfCvwXmUK/KtOxqpDFvJTF5C7r4O85W5V7wfUBuvuVy1RTWsVpvoev82VrlkU6uNM Dxu5LD8fNjVPjhbSqw9A06KwZEUE804EdIK37bEHHgfsOGbDb3sfArNbQLVce5iz7kpT KA02B1AU4WV0i6LbmqGGWKgIi+q4JZ926IgL/7bv4gRavWS77eJMw4JBFhgmUNnOwuJ1 +OqcVOYynDZi+zC3F9zNdVbV41lO9jzcQk/dlMst1dla4YbiSfKTBrscNXEQmn8KO6YQ 705A== X-Gm-Message-State: AOJu0YxpyJrKdC9NkSq+TfEIUKEp34yRpmshq34Imhm7Dz4usURf8h/0 Hefn+DH2wc/4dnAvPwlu2ncWNPN0ZadaspBBV8fmhD4eHstpc+Z4IC1MfIBNfVeNTRdQXLkUjh1 HV10= X-Gm-Gg: ASbGncukLmX8SjEzpMejrRPWC8R9zvVxMkPZ1bv755HzXPGepjJb0oAvq4dgv97AAWJ SP7DYykia/TYkYixSBcM0NzvB1hmLQzYrzhFaTHLHCCxW9O7DQURoW2+1ntLvT2DVZFZzgdSpXZ tpIbmU9SHgEi7QfkY128WX+tL6UsCasVKaRxWF3cB+WtHT7XoX1pLSqhG8l1jjMTrGG5RZFZFoC WWboYjJ1J7zauWXINrLVOhiUkaRBZYMfzkbjCy5Pp+R5PPIlws8faPlPE8ASPZwptDNIZMl2z/C TtuOyPRuNT6EjS0ZpiAWjslS6w== X-Google-Smtp-Source: AGHT+IGw0QqIIjYouW1X4qwdatObDeb4KUQsYMFNgu8rCZ/FoHIbIKxzuJHwYlHk+Cvh4i2wcVt6uQ== X-Received: by 2002:a05:6a00:ac2:b0:72a:ae66:3050 with SMTP id d2e1a72fcca58-72abde40466mr23461730b3a.1.1735070752542; Tue, 24 Dec 2024 12:05:52 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 32/72] tcg/optimize: Use fold_masks_zs in fold_orc Date: Tue, 24 Dec 2024 12:04:41 -0800 Message-ID: <20241224200521.310066-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index e284d79fb1..81ed26a376 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2096,6 +2096,8 @@ static bool fold_or(OptContext *ctx, TCGOp *op) static bool fold_orc(OptContext *ctx, TCGOp *op) { + uint64_t s_mask; + if (fold_const2(ctx, op) || fold_xx_to_i(ctx, op, -1) || fold_xi_to_x(ctx, op, -1) || @@ -2103,9 +2105,9 @@ static bool fold_orc(OptContext *ctx, TCGOp *op) return true; } - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; - return false; + s_mask = arg_info(op->args[1])->s_mask + & arg_info(op->args[2])->s_mask; + return fold_masks_s(ctx, op, s_mask); } static bool fold_qemu_ld(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC1DCE7718D for ; Tue, 24 Dec 2024 20:07:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBB2-0004kO-Ou; Tue, 24 Dec 2024 15:06:49 -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 1tQBAC-0002uo-UE for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:57 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAB-0002cu-Bu for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:56 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-215770613dbso41197775ad.2 for ; Tue, 24 Dec 2024 12:05:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070753; x=1735675553; 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=8qWTPWB/56xfTTsmE3Xx4A/juxFvaZTioQPwMgdB9OQ=; b=Ietb1wX8M8okc9D4fxzI64eMDaEgBb2ZkFENW/o8wSE+iix8ijO3YqhAB6xe83gPGN hj+PL8V8y0rxk86/1Sd9vFGKzqj6yms0j3mi7SYyzb4Yq7tg1rnLyJGeFL5F/TT7RDBC gIdynvtCa1h0w34yeHVPUjXYw71yZcHmvdmyoaYWuX4yo15NIkaMAxorPjyXlPnZWZxp WarYdPKGDMTEDYJVK2WuJoM3lriVR15R4nYeEKu9eULOoAwHKu5i8SuIgQA75skkuTlV W2TtHwYrPJ2Og2TLOd02/cYXfJUMWwBxMQinI9ltUliMnMKjrQGJKQUP9Vdm/nCT9/M0 4fTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070753; x=1735675553; 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=8qWTPWB/56xfTTsmE3Xx4A/juxFvaZTioQPwMgdB9OQ=; b=Tr3YzTRGggNBWt2teifUYkfSjGPZVhs1Jbvg+i+AtBNmhPSLq7oJcIs0W2JUAAyAO+ 8WXMEpH6Z+vJj3U7D3viRO/eLueEUEjrflvugJF9AT+nWilRrUhXZfU2jqXL0PI0XcDc aJRql7G9BRahNKQEpekYLtHZCA7RjvF2OXykkkx+WOn33zlLm8HcShWXiBWAGbnKTecN oyn45NUtqyHqCTJ8o9P0Rt6aDgY/ILZrlrjMqrBpkwz1ISmahCTqOKrt0UcAhBHBMetz Oung5pdmszFZibgnQC9cTrgXbGh29diXYYOWx/bGl4+Tmb0jU6IIS7yO2aja7EwWGc3J k4tw== X-Gm-Message-State: AOJu0Yym5dwBgkYL5ep3IZCJOPaN4V+wpGfKEWQzJ0eVq5GFlrje9PIM msMRrZ3Ig8FSQlYz+Kb5H32uQK3XJ0A7btotDbPkOD+hTkCAM15HmbDW1/+pAbeug+E6kPaSsvf MRD4= X-Gm-Gg: ASbGncsif1J9Pb4AGTRdR7UtwOU/qS4gNGCPNrj6ckhLziq18qMgXT2LX0WOlICsGLw 1KxvoYe5enFadg+d4kMpijtuvkyAyNmAiw6ujaYJxFpWKsWjRb0MsofA1yhWCizl+8lvRYQ6TS9 tPkgasj2Em3gckelWdFMPirZoCO8fieV8sNCUCCBY1rCeNMmjx6Q1i03uFGEZfMMrvTpIkJx244 nFH9GmRHTQz9DUrL+ectYUnOa4YcJnCDEpeFOWCKT04vNz/b4enutGrYApDiRXzg2cVzSpTt7S1 Cbsa5juTd9zU7sURSESjydCWHA== X-Google-Smtp-Source: AGHT+IHEEBVpTCHCpszNFb3tbvhdsU5xyFfSRvDZ9LK+sELMDBEb3A+dhf+ho9q7Z5x9SOq2ijJcfw== X-Received: by 2002:a05:6a20:c705:b0:1e1:afa9:d38a with SMTP id adf61e73a8af0-1e5e0447f45mr27489075637.1.1735070753476; Tue, 24 Dec 2024 12:05:53 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 33/72] tcg/optimize: Use fold_masks_zs in fold_qemu_ld Date: Tue, 24 Dec 2024 12:04:42 -0800 Message-ID: <20241224200521.310066-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Be careful not to call fold_masks_zs when the memory operation is wide enough to require multiple outputs, so split into two functions: fold_qemu_ld_1reg and fold_qemu_ld_2reg. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 81ed26a376..7bd17a36c7 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2110,24 +2110,33 @@ static bool fold_orc(OptContext *ctx, TCGOp *op) return fold_masks_s(ctx, op, s_mask); } -static bool fold_qemu_ld(OptContext *ctx, TCGOp *op) +static bool fold_qemu_ld_1reg(OptContext *ctx, TCGOp *op) { const TCGOpDef *def = &tcg_op_defs[op->opc]; MemOpIdx oi = op->args[def->nb_oargs + def->nb_iargs]; MemOp mop = get_memop(oi); int width = 8 * memop_size(mop); + uint64_t z_mask = -1, s_mask = 0; if (width < 64) { if (mop & MO_SIGN) { - ctx->s_mask = MAKE_64BIT_MASK(width, 64 - width); + s_mask = MAKE_64BIT_MASK(width - 1, 64 - (width - 1)); } else { - ctx->z_mask = MAKE_64BIT_MASK(0, width); + z_mask = MAKE_64BIT_MASK(0, width); } } /* Opcodes that touch guest memory stop the mb optimization. */ ctx->prev_mb = NULL; - return false; + + return fold_masks_zs(ctx, op, z_mask, s_mask); +} + +static bool fold_qemu_ld_2reg(OptContext *ctx, TCGOp *op) +{ + /* Opcodes that touch guest memory stop the mb optimization. */ + ctx->prev_mb = NULL; + return finish_folding(ctx, op); } static bool fold_qemu_st(OptContext *ctx, TCGOp *op) @@ -3012,11 +3021,18 @@ void tcg_optimize(TCGContext *s) break; case INDEX_op_qemu_ld_a32_i32: case INDEX_op_qemu_ld_a64_i32: + done = fold_qemu_ld_1reg(&ctx, op); + break; case INDEX_op_qemu_ld_a32_i64: case INDEX_op_qemu_ld_a64_i64: + if (TCG_TARGET_REG_BITS == 64) { + done = fold_qemu_ld_1reg(&ctx, op); + break; + } + QEMU_FALLTHROUGH; case INDEX_op_qemu_ld_a32_i128: case INDEX_op_qemu_ld_a64_i128: - done = fold_qemu_ld(&ctx, op); + done = fold_qemu_ld_2reg(&ctx, op); break; case INDEX_op_qemu_st8_a32_i32: case INDEX_op_qemu_st8_a64_i32: From patchwork Tue Dec 24 20:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 524D7E77188 for ; Tue, 24 Dec 2024 20:09:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAy-0004GW-DE; Tue, 24 Dec 2024 15:06:44 -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 1tQBAD-0002up-4m for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:58 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAB-0002d6-KQ for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:56 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21683192bf9so61844195ad.3 for ; Tue, 24 Dec 2024 12:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070754; x=1735675554; 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=/BIzmSJg2IBNvRjDTAJOD5BUlfsyyTZSbfZK35bezBU=; b=e9O7fo3m2xxQZD+MrWBnhPaYYVk39jM8kNseTGCP2PwzAIGJxHz6wzZCBlwZ2pknvH ftr8dAVn0GL/BxsbXJJPagP6xu9MPYRKpGgM0fZY3al0hy4r9buDBykwWNdTgG583gW7 VFvGfkYXgTI6CEsWoHHn+H7j25Gni/PLg72sOFBMLZeEHNc9xH3TpKJK5UQukGYCuvZY efSC5KgcEZ5JWbFnn1VTwpadJ+cUVIgG0YFzafUttIedmNkn9xz0/G8peH54AqgSBWz3 4nsVOSHmQHH5/hZLT/o/Cmbv0HuyWpVNkJ1g71OrZE/jiA26egFOvyLrG3bFqXwInje3 lFVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070754; x=1735675554; 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=/BIzmSJg2IBNvRjDTAJOD5BUlfsyyTZSbfZK35bezBU=; b=jE3+F7T7IfIrLoemcrBTBuosM18mJtTPIgWI2KKGWCknws9Y5n3zdl+YC40kYgkD3Q r17DJHGrBmEHYO7P83QsBLGyNrQM+TIJpa+VOO9XnBaMAc01EBPoQm+chWRz0RAQKaCm IRTIs6ON4UJBJ2Bl0IkwnarbdpCiCEcw03wLp3fObD98TnYNtoqZoqhIOVETMNG+HBLI RGcEzjfaGtSkB+Qa9dyzqNrOJHAzAYE8bvBTa6jIdFBquqiXVfkJkaxOo+FEhgVRYWBu 4H6EIgkGnLOy1jOAloZXOjkAKkzUSV8H2Gn82GRk7NgCeIOPi2zUr87dUBlRcZPrMT7E 1Cpg== X-Gm-Message-State: AOJu0Yz2jek1ZIK6Yabuz3QBwQmJdlG9r9hT1fvklhO8laGZjY8O2b79 k0W/UlKdwbO5+EnC0d9X798gH9i7JACZt3PtGusTk13ZA8qF7ohWbQxMtv0SWCOutDyXtuDylIr 4H84= X-Gm-Gg: ASbGncumC008be/FFVDPpKvb6jZlq7adldF3fHLgHj32b2EsPhgRQmFHSdsT0P6+25c B8Ga5ty7Z5nK3NzrjZft8mcWHB+SlUJdKbWd0fDGpk2TzOT/OoClFUMDwsZWDPmMdCaJfN4KfN0 ZcivGcpv/TcbKGsTH2W5UgsTHIQjkKVKeVd5EXsAYiKvw91DWrQUDAZObkqZkSe1GOgCfGho4Y3 wdwCr0PF6BxMtc84HgdESbhD44ldc3cW4+3XtVanWjk0Rh9LY+OKFsdLti2wSLGrBckNyv9ZnRa L4EtWKPV7X89o8lbzgUjLfdviw== X-Google-Smtp-Source: AGHT+IF65FuvGmVtOqnWIzTLiuuH9JlWod7Ax+vaaY2itZYA44QCU5hVb2SluvTrNW9NnXxZ0jgAKQ== X-Received: by 2002:a05:6a21:3987:b0:1e1:ccfb:240 with SMTP id adf61e73a8af0-1e5e081d78cmr29133019637.41.1735070754356; Tue, 24 Dec 2024 12:05:54 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 34/72] tcg/optimize: Return true from fold_qemu_st, fold_tcg_st Date: Tue, 24 Dec 2024 12:04:43 -0800 Message-ID: <20241224200521.310066-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Stores have no output operands, and so need no further work. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 7bd17a36c7..07792c5351 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2143,7 +2143,7 @@ static bool fold_qemu_st(OptContext *ctx, TCGOp *op) { /* Opcodes that touch guest memory stop the mb optimization. */ ctx->prev_mb = NULL; - return false; + return true; } static bool fold_remainder(OptContext *ctx, TCGOp *op) @@ -2706,7 +2706,7 @@ static bool fold_tcg_st(OptContext *ctx, TCGOp *op) if (op->args[1] != tcgv_ptr_arg(tcg_env)) { remove_mem_copy_all(ctx); - return false; + return true; } switch (op->opc) { @@ -2730,7 +2730,7 @@ static bool fold_tcg_st(OptContext *ctx, TCGOp *op) g_assert_not_reached(); } remove_mem_copy_in(ctx, ofs, ofs + lm1); - return false; + return true; } static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op) @@ -2740,8 +2740,7 @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op) TCGType type; if (op->args[1] != tcgv_ptr_arg(tcg_env)) { - fold_tcg_st(ctx, op); - return false; + return fold_tcg_st(ctx, op); } src = arg_temp(op->args[0]); @@ -2763,7 +2762,7 @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op) last = ofs + tcg_type_size(type) - 1; remove_mem_copy_in(ctx, ofs, last); record_mem_copy(ctx, type, src, ofs, last); - return false; + return true; } static bool fold_xor(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD82DE7718E for ; Tue, 24 Dec 2024 20:10:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAx-00049j-G2; Tue, 24 Dec 2024 15:06:43 -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 1tQBAE-0002y4-5h for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:59 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAC-0002dP-Lb for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:57 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-21680814d42so52215035ad.2 for ; Tue, 24 Dec 2024 12:05:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070755; x=1735675555; 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=JbV7ezqIGFwEAzD5BKNZbxFvhvTByi12RrhcY98hJws=; b=xXLKM4kFYrGX7RiViWCzc9XzH6BfI9I5Ylrn6AicxTBNZaCcSGkYP46lQcDrtG32Yz DH2cUbQPkgXNLSra6hk3feMcx+usx3WHolQvpKOIacr6sPLNTOZt35CsjcbbLcgRxbwP 4leseye2NBacgwfOKzje5DSwwDU8Rghh+uxR+KB2ls6jeJYWwvkZh1tg9yTmEZyMOtLW BB1BSUozwzEy/9ecgixvXiMv+X/mVN4IUT+83ecwu1kWW1MPIx5RNF0uDIz9CnTGyVe5 3okr02jBf0OlKsmVvz3kk7Bpnz57+p2/PlvEXIEYZ+takVJfLzWZB+Tq5vuzxnRGAbVq Ifgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070755; x=1735675555; 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=JbV7ezqIGFwEAzD5BKNZbxFvhvTByi12RrhcY98hJws=; b=IHS6eSk/IxSYs0vImqaNGDzy/TCvLvHIL7OiWdMAlHt9A0A3/3MUsSYuwvWDHWDU5T An9tdViURx/KuvhyIoRLtJ4QLqjykCXeVA2RV4MttZMHTZ6hVghrbt3mz3IF+JFoIow6 w8lagvSaS4EX1676P8E6wIC622QzvpF3+YXs403A9KCMkNKz30KXGz9M2NzsMuuDVhaC /ReQxCl6z9G8U7YQPrDgOQW3S8izDz5MSHR9JgTXZm76MAjYbWCDq8GnDnRkY0U1TBuJ zpDubeXDv3zsGRGA98c50lxi74Dl6L5Ljc0NRUTYvvZtUlnB9cMGv+egF++MMMG5/win WbHw== X-Gm-Message-State: AOJu0YzNInejlDakDVC0L2j1s8Pp5zXqs+TncWVlEtLRGp4ReBcNqABi QQEuoZ/2zU9dLhmzA/tL/G1FODVHw89vNNcuTVjhBgmyraZJCpipDEtRiDN3fIvbHXx59RcaC/z MY0o= X-Gm-Gg: ASbGncvG4BT8g/1GLv0ov3r6bDQvSTR2J/Pw/dgD/Rhf4kJbW3AQEx8qCcr6syBQYBB D6n3DelXK5g3lKqO+po44PFrb0d6d98xHaEcfB1vJruNeSSgd5sIE81krZyskbLCbAbxviwatxX 6evy/cSKzzcuu26rWG1h4uUZCe4sXcyxoQu+8uGCZTwkWZxMnLWIAf5Yx897t1mzLNwmuvoRem9 DyphBANeX/jhWhAl0YcjGPE2fGV/lKTIvaQ1V+Nv/0zRuG80eqk3BsrkWAg7XCc7l5KoVVNF5ob R13vWhbDdX+dcsq66/KhXDafDA== X-Google-Smtp-Source: AGHT+IFZ8gM0uXHoR2APVEDoOHqfSyNnge6oyo+GEbhHN2FXdD/iPsEv5n1FX78gERtM/x0dmXfBXw== X-Received: by 2002:a05:6a20:1588:b0:1e1:e2d9:307 with SMTP id adf61e73a8af0-1e5e0802532mr22399254637.33.1735070755101; Tue, 24 Dec 2024 12:05:55 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 35/72] tcg/optimize: Use finish_folding in fold_remainder Date: Tue, 24 Dec 2024 12:04:44 -0800 Message-ID: <20241224200521.310066-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 07792c5351..e78f5a79a3 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2152,7 +2152,7 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op) fold_xx_to_i(ctx, op, 0)) { return true; } - return false; + return finish_folding(ctx, op); } static bool fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg) From patchwork Tue Dec 24 20:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B8ADE77188 for ; Tue, 24 Dec 2024 20:09:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAz-0004Iw-5U; Tue, 24 Dec 2024 15:06:45 -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 1tQBAE-0002yL-RV for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:59 -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 1tQBAD-0002e6-8r for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:58 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21634338cfdso79720935ad.2 for ; Tue, 24 Dec 2024 12:05:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070756; x=1735675556; 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=KTUO0uF94ggO8DLruNGc154B1KXBI7ow/g7ffKKGvr4=; b=aeDKKiBsClZ3Hfde1gVNPsU5MzqNr+Sbe29iQUDirxarUNVY7EEbpnjgRGu/g9Mdj6 Qu3AMohNY6S7piJ5j4jsLCH1vnpoQfCySit6B+dbVXlhSko8pAHLwVfHpaJGCjRTkoGM EN/Xyd41y6uCf5MW1hmRX97kHUXx74RfqsqPLQyUph8cLQa2aEdYQxfV+9kiFqXLTbdn JbEgyuPSOxHbh40kKK8is8eXilYNPp7XUPpkBxN2ol7h5B/jf70VXqAP/Vi9vq2tf0J1 65dwl9YDV2BGr1L3JUuicH5mLq3eX2YLH/SAojMMxfaQn+mBbTPLaYLnTDXXneXhWEbO 38gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070756; x=1735675556; 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=KTUO0uF94ggO8DLruNGc154B1KXBI7ow/g7ffKKGvr4=; b=UbV9Vbee4u1zvsnyFLallbkmV1gKKIpeJk7oUUu9j05NKnHFmHBEejucG+LLq7SBhQ J939gWCda/mWevpRbl5eA+AmU/Zuk7zNKR2G68bojUPxSe2Xnrt5ciCOfjCKT/PeAmrR 0JS5Tynnvy8QzkerhNSFd5fiRJ9nTB27e6yCXvhdxVZhy/Qh1Yw4XIBXFa7h4P0vk88k 15cZ58E01L6eNOyka1fvNBYd3tFhRsZXO3ZIe4VJoOX391SvhMT7Ae6uWyFw/r91U+bQ ZEXO+DG21L7r/u4hd+b+Fk/9XUf6R7A3lj7WOdE0mhXm49as5dktMgD5HQUs68jF3CVr LUYw== X-Gm-Message-State: AOJu0YwQ7bF4iBJBGMiplS0tmBxP2S3ugqF+sK2+fMNhDDZTc0RSeo/M 3TkMA6uysmXmlRXRVPXnr2Wyp5Paf1S27z+fmxDo1ZGRUDpVUOsl4YmsIrNT2cE/6SShbP7HvPg pShA= X-Gm-Gg: ASbGncsgt8JHsAS6xa9lLro8Zmr8cqSN0fAInlTQQtpVmBXCjTZl1+L1seGN6H64lX1 lCiz88KSbm1Lk66lJHLkabEpu9q41i/oTkO+JrFNjiPMj3SSDpLZeyva2L7mmsNszVN6U1Fl3kF 8itnHnjmiq2dSDn7yYyy/JkBch6E5zSmyHDPMwlV78RxeDLHRz6h9PnqgSpvO+pEBC+xUR+npCh k29o5tD710C+8rUboj3YpLGk5U/FihUdJcx9ZHNX8i8F5KplWgH0TqKGlbKEi9z68AlwXBjIj0U bWnA/8ABsRtNhbtfNnx0BK0o1g== X-Google-Smtp-Source: AGHT+IH7hDttmrGY8SarAQL2EvDau3KT4ilPoFmFbfWryvVvi8NUagtsDO1Fez/8nbzgOIhWkZZavw== X-Received: by 2002:a05:6a20:c907:b0:1e0:e07f:2f01 with SMTP id adf61e73a8af0-1e5df939d84mr25801344637.0.1735070756035; Tue, 24 Dec 2024 12:05:56 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 36/72] tcg/optimize: Distinguish simplification in fold_setcond_zmask Date: Tue, 24 Dec 2024 12:04:45 -0800 Message-ID: <20241224200521.310066-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Change return from bool to int; distinguish between complete folding, simplification, and no change. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index e78f5a79a3..678015a94a 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2155,7 +2155,8 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op) return finish_folding(ctx, op); } -static bool fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg) +/* Return 1 if finished, -1 if simplified, 0 if unchanged. */ +static int fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg) { uint64_t a_zmask, b_val; TCGCond cond; @@ -2250,11 +2251,10 @@ static bool fold_setcond_zmask(OptContext *ctx, TCGOp *op, bool neg) op->opc = xor_opc; op->args[2] = arg_new_constant(ctx, 1); } - return false; + return -1; } } - - return false; + return 0; } static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg) @@ -2359,10 +2359,13 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) return tcg_opt_gen_movi(ctx, op, op->args[0], i); } - if (fold_setcond_zmask(ctx, op, false)) { + i = fold_setcond_zmask(ctx, op, false); + if (i > 0) { return true; } - fold_setcond_tst_pow2(ctx, op, false); + if (i == 0) { + fold_setcond_tst_pow2(ctx, op, false); + } ctx->z_mask = 1; return false; @@ -2376,10 +2379,13 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op) return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } - if (fold_setcond_zmask(ctx, op, true)) { + i = fold_setcond_zmask(ctx, op, true); + if (i > 0) { return true; } - fold_setcond_tst_pow2(ctx, op, true); + if (i == 0) { + fold_setcond_tst_pow2(ctx, op, true); + } /* Value is {0,-1} so all bits are repetitions of the sign. */ ctx->s_mask = -1; From patchwork Tue Dec 24 20:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32526E77188 for ; Tue, 24 Dec 2024 20:10:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAy-0004E6-5N; Tue, 24 Dec 2024 15:06:44 -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 1tQBAF-00030W-Vh for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:06:00 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAE-0002eN-6D for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:05:59 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2163bd70069so55721945ad.0 for ; Tue, 24 Dec 2024 12:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070757; x=1735675557; 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=8h+Y/eSzKzpzMdEwoTVhqBqG5Af8LUZfpY4qbcHSiqE=; b=vCfSIZC6J9NwykaRVy+M8ysarYmX6Zyf1VpYCvABTbrg55FyCNHiHO4WYVFHhZUY27 caZPspqae65GbcmJigVlqDtOg0mGhrVcwofLY0P2DMnbCYY2LJpZAYIY3buGfo3wDUAB 4qjJioIMcZAO62qo4UG4LaXkjj0pSDuhiVdGRAjkrqBx6r+c43NxDZCqrebfUOYOUbdB VY7W4VeWgMkvCTs8qC4oB1ZA6zD8Z7hTGIEJjHuOHkPpnaLQIIg06U3cTYFoIcg9ipJb R/lOUY7eYG8aUiXicBt++OXddAQ74g3GsIOM7Tt95wSgMYLjV5/nGWv9Gx2ZhJHGeU5f /mqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070757; x=1735675557; 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=8h+Y/eSzKzpzMdEwoTVhqBqG5Af8LUZfpY4qbcHSiqE=; b=HIwQz/jxnK11Rep7l9qg2DFJ2VZoUizVs8gffuJ8OjF16Lb4vRDESAzuMrEYPkXYrM OyIbBgcd1zdPM+MyX9mg2oWTBJlti1JiUm7tk0lqMcdBMXZ+idEcuD4CAC7hZoUNI02O XOtphRAz6jKmoS6P6Vl/CVyMUJFpobndnYRvaCk7xekhqaAHA8CbC11kL2C5hE/X9fIh jQQ+4r+jD6NmP42r2xFvmR/jAIqopeJyR3TRzh5DqCNXfgeGmuh7uA/xGBzVJ/WIbNpE qdnoexdEHddtB35Xuakw1j3o/BV19ISTywHT8pvFQssiZRcw7UHF5UyUJQjHCjN5WM86 KBQQ== X-Gm-Message-State: AOJu0YxOlNQXWhj+komtXWLQ6MW9hRepA0cLNQm4pw7ZSoazRH1beT0U btiLq3sadeuem5uaWBqI9xOlK/71JzQtubSDlIJvpRNUNSebOw6FpjRiZA0Mv5gmkn8KP0PPRvc SkGU= X-Gm-Gg: ASbGncuy+XTkVgEkDql5SDDvup6QL2CoI+/21FzBBGjvsy6NBhvc9WhyArLhJwCTIs9 yTVfLbmlKs3HkJcrq7MAbMsSmwJTbsfutz/OtAZjELmb2oiTubxr+/sDEtifyR+vmYZsdXoO5+D u6dl5KEe+Wxqoozzg5V2i5fT6Mabl8tfhY7iPKq9RDP+b6dfYVPAiap95i3BPdKW8pysfGM3Lua toXE7SVzBr/8ztOgvt1fvJkxURJGjA5FAvPECK5TEGmmODiaGwnHRR2tlw+oVHXQ5VzfXRr1+wO UEr5SN/1JeKdVcugcEBBJVdNpw== X-Google-Smtp-Source: AGHT+IHgayS5U73VtZKb1EdZuWW/1r59vd+RxTBSpVMVW+x1e/2jiw9B+6okBe+BvgXy1Sl3hqFxyQ== X-Received: by 2002:a05:6a00:3996:b0:725:9d70:6ace with SMTP id d2e1a72fcca58-72abdd8c362mr24044015b3a.6.1735070756949; Tue, 24 Dec 2024 12:05:56 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 37/72] tcg/optimize: Use fold_masks_z in fold_setcond Date: Tue, 24 Dec 2024 12:04:46 -0800 Message-ID: <20241224200521.310066-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 678015a94a..74be827f51 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2367,8 +2367,7 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) fold_setcond_tst_pow2(ctx, op, false); } - ctx->z_mask = 1; - return false; + return fold_masks_z(ctx, op, 1); } static bool fold_negsetcond(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0D2DE77188 for ; Tue, 24 Dec 2024 20:09:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAz-0004Ib-4z; Tue, 24 Dec 2024 15:06:45 -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 1tQBAH-00032U-4u for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:06:01 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAF-0002eX-OG for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:06:00 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-21683192bf9so61844775ad.3 for ; Tue, 24 Dec 2024 12:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070758; x=1735675558; 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=BQkzcdNzyFSe25Uj6LgRouwEG7p0lTXXdxR16Ve6oxQ=; b=NCkHWIK7DrSu01sUQ0JRCv9jgCZyJ6R3JUX5oJcIn1KB9US/EtDO8e2yYceI/xIYrY 25QgfSxI3HYw3NYlQKE5upeKNTOCvSY1UeAvnj4WfvwDCLZyF8S9JYMOIy4T9YIMxP7d Owg1BV8Z/kWL4zTB9gw2dCUIf6cvc7qG8iBTQ/37tJZynFvfuk5GXXs2TxQ9/1C7g/Dp MVLwLYSxDoNa3pcEcSdRWPfnMuJHYoczLWrd6nlTM9rkVVnoi4gErJ6Vfru87JxhQ9bX FUfaS/rp3IojAvjL/XGNbhiH24MoeN3n1q5rZ5M7EDbCZXNMXwDpwOt5I8MQfUNALGko 2TOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070758; x=1735675558; 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=BQkzcdNzyFSe25Uj6LgRouwEG7p0lTXXdxR16Ve6oxQ=; b=emVvF1lp9NcmhV6Ste1wcg2g4467AsuQRwYf8ekSsAe8SoIwwWd8c0G+56+jBIjQjE f1EDcLSUDfgXQXagY4mxbhuurRVnp2l0FSSDtdq7cvqDYf9TLIC6AZK3UYfBZ/zjg2n5 Iw+t8gccIB47R4ItUE15B1rlYLFxU5QY/E/pPMDx3W8O0VSLbqHE5FVLjkMG3I2byntt /8r3UdWefAlBYtGe6krSFLOljECsc8wpZNnZO5irz9gHOwcpwZ+7pUmKmEhHrM3mreAJ /5OxAunu4h0JBjNmaLWMW744bc6+S0XA/7acrzrLokV5APXl9jgnWzFL8JB3gRxF2Spg sLiw== X-Gm-Message-State: AOJu0YznA2C6LWvJsYDCYuaoa3LdvJCYdc9/tI2orbEr2Uk0IhK9zo+O 4B8F34XX7vC0G1IJaT0/rLIOJOAcKEEolQud1QpH2h8OZ3jGyh11bH+dvqHc4HzrjmQNBb7HqOl V51k= X-Gm-Gg: ASbGnct6ODd9S2+pxrssoOJZr93fd9NTpErSVe7HckZW+93tOogK8Q+9PmXJ0h1OTFt A3zzJY9Lub8EhLe4Cwwc7rM3qJs//eFktU4DT1vJyYaw46fKt8vPXNZHtJoM9NLuUks6lBUaPdh qS8JVBCipQIcAzKvn96JRkyEJkZdUjUZulrPnkRLmVz0G6/dxOFH8DLIlPrJoN4bG2HVyKCayez KTKxVgQcKNWjzb5B+z8PabYCFG0/ATNMPd/l1+nCxDb/H+i4+mT4t7Ys2Yhe9q+UOqmPmmvcFbG hmZmbKqVrIc+AYuLk6dUnbZLvA== X-Google-Smtp-Source: AGHT+IHi6Nekw9Mvn0n102hNVKNmVBp5yHj+vsvFvSSzJVY4TZ9z/AnUh+KsUrnwsurcfefBKOhI8A== X-Received: by 2002:a05:6a00:35c9:b0:71e:6c3f:2fb6 with SMTP id d2e1a72fcca58-72abde65a60mr30910900b3a.8.1735070757848; Tue, 24 Dec 2024 12:05:57 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 38/72] tcg/optimize: Use fold_masks_s in fold_negsetcond Date: Tue, 24 Dec 2024 12:04:47 -0800 Message-ID: <20241224200521.310066-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 74be827f51..7e909791e1 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2387,8 +2387,7 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op) } /* Value is {0,-1} so all bits are repetitions of the sign. */ - ctx->s_mask = -1; - return false; + return fold_masks_s(ctx, op, -1); } static bool fold_setcond2(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AC4CE77188 for ; Tue, 24 Dec 2024 20:08:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBAz-0004L2-Ls; Tue, 24 Dec 2024 15:06:45 -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 1tQBAH-00033V-Bd for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:06:02 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBAF-0002fc-W8 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:06:01 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-21654fdd5daso55266095ad.1 for ; Tue, 24 Dec 2024 12:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070759; x=1735675559; 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=KrkS8wtDk9FFk+ALiPIq/W5dXJBRwDqMCYe2mtixhBA=; b=t/9xYq5xwkghOjepIImjrfYpyRW5mIwDzW9VzfucK6X85BXlqV07sXtO++55BcItgr aGESLnYES/BazxV2DkS3rCJJrqdeUbNG3XX3gcV3nna8BzOvPzvtBhcphek67OshKAWt /3Q0rCwlO39rJsZ4gkWgOrUZ1hAU6dgyIrRvQJ0dF+4r2amKRdgweehM5LsGYa5b8+CM hMRNXFPMr/NrT29wbnFmtd4BfFKjmZ+6N3PjglviLKSSjlFMLmkAjKCXDN1IMTCy/6lm TKtA+pbEEUU+E7mwpsR+wkNBTKB/jun1O5GhI+xq+NEMO4elixqQOmUNjjcQLmEQLaXB oOGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070759; x=1735675559; 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=KrkS8wtDk9FFk+ALiPIq/W5dXJBRwDqMCYe2mtixhBA=; b=pXSlF1hlIGeZxX3gQ8Pbi3/jB5BSk7f+rinSVnRjMwx8FdgQatiJeqP23CJ3TSwvDV 0QhB028rQvsm6tO0bjifx52acJ72AiAEzjjaYmaPF9cGpWLjjHM4ZOrfiVnYJktzIydu 25zee0+143wjFn8/e0QXfH3/X94Qxphqz0xb6YZG9aYo7t1GQdQj+vr+nOZZpT5xJCiE bCDiTFEOMzu2ZyOA3nk1VCzEcFlsA+/5rrFF2ocbx+J/yyilfFDtheVl3x042G/pMwEx i8aklLwMv5nx58+XiIY7OjhrB6wzN1uSH0pCpwcjpDQ8qGsNqHY0fGu07I0dTHL4Cjjt tIag== X-Gm-Message-State: AOJu0Yy0YYgf1nFgsHzukBB1wpHJ62RnJlhTii8/D/xC5ztBSP5lKeRl aZdNTTz/Zrf7eVEOxDK3lw5Xpr46wDzCaOSL8ryidSUQftSuWgLwOFZQLMQm4OFzxMxdo304zKe MPV0= X-Gm-Gg: ASbGnct56ucb8/Nssz0xs74t5nX2loOcHAioN1OpiYhdVgpfxiz+6swlJao5U+XreCW 7skRkoBp7LGFBt0Y1WKVEO5BD8v/A8gPykqywVYmgLsjUJyXxChFpRynEUhXfIn9vPU0leDceYU 0XKuWA51yd0xBxQxQ6rkP/rGTPyJQRDzsmiim6nq5sZGA5dq9E6pDdIymRiuYhq4zYLQMNMk5GO WcpGud/gWrObtSlKALCVUWx+gLV1AgDpLChn/s4hKtuftbjiq3oAAjEUUMRRRz40qUjGX0CGQDQ dWbzdOrFjudeJ4TlotOhiu11iQ== X-Google-Smtp-Source: AGHT+IGG9eWFq7JIjBraoV52uohaYBu3Z6SHgTkBXwPV4eZqafRBFrRqOi5b+pinK4xHTKae2RLILA== X-Received: by 2002:a05:6a20:9144:b0:1e0:d169:ee4b with SMTP id adf61e73a8af0-1e5e045d6c5mr28075812637.12.1735070758676; Tue, 24 Dec 2024 12:05:58 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8fb895sm10027159b3a.162.2024.12.24.12.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:05:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 39/72] tcg/optimize: Use fold_masks_z in fold_setcond2 Date: Tue, 24 Dec 2024 12:04:48 -0800 Message-ID: <20241224200521.310066-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 7e909791e1..c61d0eae4e 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2468,8 +2468,7 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) return fold_setcond(ctx, op); } - ctx->z_mask = 1; - return false; + return fold_masks_z(ctx, op, 1); do_setcond_const: return tcg_opt_gen_movi(ctx, op, op->args[0], i); From patchwork Tue Dec 24 20:04:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36EFAE77188 for ; Tue, 24 Dec 2024 20:09:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDG-0005Zp-Ac; Tue, 24 Dec 2024 15:09:07 -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 1tQBDD-0005Pp-J8 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:03 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDC-0002up-3i for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:03 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-218c8aca5f1so66387505ad.0 for ; Tue, 24 Dec 2024 12:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070940; x=1735675740; 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=1RODzffUtUxINNUBBssSAHn/zSJ6hm+VWiAhpzm3k/E=; b=wDVo3/t4PYaN+gxajcQ8ppA/HJBzaJTrRYsijcfAoM5S++EmUwb4rfybtBGHa3NFGk jMErJt6uaknxeY90otCUBRZYs+PvYAlnmppVzIDNxroo/qE2C9aKz0iuL7ACRZspzjXv w6lHzH2PnF6OPk+KpwgtJwJC/TcQIGOTldn2fFPr78vPi4CuVZwhxifCOG+v45clkdfB ytpQPWyS/TExyTJr/afAm4vp4icbykTiX8R5+F4gf34FikrRjOsju+wKUcwG4HgcZknN EG1xW7F4gC6O8oKjzzlFbcngSqH8j3JGUUBonocZAhMOYXDfxVxMg6HS9j6OgaCsKNZd Hphw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070940; x=1735675740; 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=1RODzffUtUxINNUBBssSAHn/zSJ6hm+VWiAhpzm3k/E=; b=NcMcXTCnXzjkePuZqHd6feFW8uyGIU+axkbWglQq6aaBMPuI4L60I2nZi+0SVrtuor j01x3AxCIPLVuFHrqa58joMO9+1HgLzbYPKH7yG17GEGCg/pem5IEpwoFuNqbEKCaj+p Y7XR0ht2/0sL58iuQOUJh9POAEgALmctO5uvmdAnHO/IeGgWGrg4/ZsdGxpEadHaw614 D6O6CrcBQkOoGrBQf0Sf9v5Be5UkveQFcPtNw1Wvyzh3GzXXRrdxzpxWoEvjEO+LXRxj nYbRVRBc9zKuJGG8dBkJTdESVWp5SdL3ssHq4RL/IC8gOBAJjodUlgd5EiI8k8Kd4PpP 5yFQ== X-Gm-Message-State: AOJu0YyLIA8dp7uY8OHBsPh43VJlvn0nsaQXACcDd7UhN/kTeTRt555I 2h/riwbMd6VED1ggbBqB6AQo/wyMLZst0jy9ygve1nkj/yJT028TdHOX61n/5ecSfKh22ofdIqU 7KTY= X-Gm-Gg: ASbGncuED/uAkNk1JrhO6HyCVX5hJVwUraAmf2wXvKzoG7QTmVs+jEDIwQPz+OyvWag Brh62HcYj+Dq8OEzkQP9HqKY+FH3q6RwnuV3Xdi6apflaXBxL86d61cmEbprq2ymLhnx0WOGyJJ V2IDSJyeGIc15kfj5YH4aaxooAB/zpxqn3ujbUD/mwcCXDrkcbthdRcWIp1401RebYaf8MP8mvQ qfd14YjZoz0zOHJrHWqZ3jaYkOI07C462DTpSdah24Z2OxgsAW3MnpHqSvOiygJY44jXwy+lzgy smkr6D/yzzrMZtIZntuQbzsM8Q== X-Google-Smtp-Source: AGHT+IEgO0wpSQUuLyabT45OOJ4WuBq/QwluoLTMRBwb/NbrHL/SHPb75KGyXMNfuMZrqH6l0mQ9lA== X-Received: by 2002:a05:6a00:1909:b0:72a:bc54:84f7 with SMTP id d2e1a72fcca58-72abddbe0demr25550027b3a.12.1735070940413; Tue, 24 Dec 2024 12:09:00 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 40/72] tcg/optimize: Use finish_folding in fold_cmp_vec Date: Tue, 24 Dec 2024 12:04:49 -0800 Message-ID: <20241224200521.310066-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index c61d0eae4e..ccdac7b7d7 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2480,7 +2480,7 @@ static bool fold_cmp_vec(OptContext *ctx, TCGOp *op) if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { op->args[3] = tcg_swap_cond(op->args[3]); } - return false; + return finish_folding(ctx, op); } static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD7F7E7718F for ; Tue, 24 Dec 2024 20:17:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDK-0005yA-RA; Tue, 24 Dec 2024 15:09:11 -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 1tQBDE-0005UV-8C for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:04 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDC-0002uw-Nw for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:03 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2166360285dso57567695ad.1 for ; Tue, 24 Dec 2024 12:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070941; x=1735675741; 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=KwVb6jhXptH+wLf21qGtM54iqz3y5j9Rj2TRVse+NVA=; b=WWeS8WFURnZjaMYNS9eNduIxP238ZCMB6E05CnUMKBaWPFgE7Ujcus8iZX7mvjcbIu eqyXxUdRLuOW6k0T+QL4fCeWvv8yiL1+IaT8DbDlm9u6YToTr5A49GktY4EO7hJwXKaf 8TQwvqy6sFjQgxhLE163FpHn72AmukUS9zrfhwVenCcwC2CPpgrq2F/ae5RpATIGHL0G o9RjlS22hLtD1RlvxXHyethbbHkFmGR2Qi3BozoUqJB+f1kIW/OMcKcbWEVV6VppzHZO WhROEYNk5VbzbEfvipXrJWdLwbn1UWbmI6fzYZazjqHSR7nzcLMgEVtbJ+80hh/ln5X1 bmuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070941; x=1735675741; 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=KwVb6jhXptH+wLf21qGtM54iqz3y5j9Rj2TRVse+NVA=; b=scP85/MniSCP9rM5rtmL0cBfW5orvTVK8jfy8heNTh7vpzQUf1sJ+1O8EaTBbq9RZx i+ygo79AiGGo2amIbEJqV4h7krpSuxx4tF7EDe5bV1+PG3Vt6kpmMoc4p6nWNw2bvnL5 ZKLkTWJVVszokVp7GYXUyLwwQZKMOqaMyOr0rksmSvPjrn4L4iFFnq+E2DNiiWaPWQ+W M2fnVAHp0u9geRUknZ2EvMpB0nk7gXj55caVHaXuwDUxttInAPXTMSxeLaVFV44lDikH /dagoTmN9rTXbzdU1N/cSkaSIn8Y+8INi/KEit8h+I6m3lVLdev6tsesiAfSr2gvs59U lrwA== X-Gm-Message-State: AOJu0YyDSrJo+npDOgAhLBgAavFBO4WBnO1bqWVwakEKDFji6swpyZf2 um4C5A+sDsLwJHEdvhH5lthpI0x6xpH9JIpltMuvPSNv8m0B8tnYh3EAWRqYs0fPEzJBNcvkFJ5 +KLY= X-Gm-Gg: ASbGncvqLETjiUthTBKrAmsQMWxXJ+XN7P6FBWl0RiPX5A2uyMu3Hyb1EjRVmVRXsll 0SgiMQjq4NT1i5za0INGYteEVFVaKsFxZGenoJV/jH0EqH4NCziB70m2aeS4Jr/kvAONIfglB9E aWsrI4kz3kUBO9s7T7Q155aUHVZC9lfJuIiF3ZYYq0zl1zy/aLe0E1uDcCOPUNbOUS9sIOAtyln eTG+eVF460vpskWJNsYWKp35jEAYFINHPeCivTfLqqEdjNC8wd6wF7oV9hUizPaKxxNOkHU0hdq qoBX5KNMP/+FTgYbIr0P6Bqsjw== X-Google-Smtp-Source: AGHT+IF711Co5HyMxZFjBqxV4pnrC/foHncNzw8ma9uvp/Ur0azeyf6aYk6Wa2ze6jk5Fz8BNiDT1Q== X-Received: by 2002:a05:6a21:9994:b0:1db:ef68:e505 with SMTP id adf61e73a8af0-1e5e05a9ef2mr30884582637.20.1735070941285; Tue, 24 Dec 2024 12:09:01 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 41/72] tcg/optimize: Use finish_folding in fold_cmpsel_vec Date: Tue, 24 Dec 2024 12:04:50 -0800 Message-ID: <20241224200521.310066-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index ccdac7b7d7..4090ffe12c 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2501,7 +2501,7 @@ static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op) if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { op->args[5] = tcg_invert_cond(op->args[5]); } - return false; + return finish_folding(ctx, op); } static bool fold_sextract(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 280BDE7718D for ; Tue, 24 Dec 2024 20:14:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDm-0008QG-FC; Tue, 24 Dec 2024 15:09:38 -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 1tQBDF-0005kJ-4v for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:05 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDD-0002v6-KI for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:04 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-21670dce0a7so73943235ad.1 for ; Tue, 24 Dec 2024 12:09:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070942; x=1735675742; 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=Vqya82Y36HRWm92cvOJyTlH+EENkrrC20W65fSXxCcU=; b=eXpTnONWs0aX4C+2om94tOcjCyePDt1LgYEhQQs857PlM7M1IQBcBiiTwg8sR8CUav mAqiLCPE0pKSgmz7kgR39LHUFDmxnPpj5sPqA6ie2vM3UktJjlZ4Tlwrf+Zx+cVNNVl0 +gDDXQ36xC8P45AE0fpfOxudjSb+B0eNCqU5mquJNyA/7EOK4wYf/YtFX3uscW5vIUxc bLDPwLdf369O2wvi4TJjRRni/A64yXrvT2PmoxPcRIu/kSOc372TUs0gTFGb4rKHyVkL rQ5HjrR6ZjWpoTwxQS0x9ZFbdK3vy2KBzmX+BzQntrzpzTjnDjdz/LGdYoYOrjSwAfrI WrsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070942; x=1735675742; 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=Vqya82Y36HRWm92cvOJyTlH+EENkrrC20W65fSXxCcU=; b=RkuhOUzHOkKYARblQBlZEWJQa5CTXvVMXgBEPZzYdCOOg961rwoNV0c1vP3irmHBMi 9Z6nZLU+x0zPZvkcJLCT5CbEts8A8X+XtCizSYOQBwDdHBy1FfEzi8fjr0gNJoLijuRn 1roO3YlJnrYFN38rpsbZ03CjdXZH7Utcy/tFJvMJHdGGeTML105co7EbRzraJqhL/95B cvZ8pcSssv5+65mEi1Oo+Curuax4GWkYoY/A9mNO7kQaOx3OfwHljLeuU2hX+WD0NQ6b D0T8VivNjs4ZVGR/u8pgnyzWwG6i6j6kGhLMALLAfFMBrzlfkK74sn3DSm4St0c0yQgN 3Whg== X-Gm-Message-State: AOJu0YyqQ1ynORIMTnsmv1x/edLdVprbfjCx9BHiMHSwMd+5fdlRU0vc QPvOFM/3pF8IggWlzG3XrdmvzAugZGtr17p/WpC2+zUkzVDFh3IjV47HgMfbP3OpcM2dKE2RVCB wpzk= X-Gm-Gg: ASbGnctjq2RaNYr8xHn5cjBOihUFyV5GhYpQhl14lW3sOOAS6fLYpAIBrbPjD51p1mR x6wepr3HIjYvUD6hARVH5PWZQdw5joyaplB9iLL6YDmvWK5poPsIWgwk5bLWvHdkZoBB4zPl5FT k2UzG2N49X0eE3FsFKjXQ19RA+n/BKMAp3gAA2sw3fVZW7qUXXfm7EZxQx5LU0Ux7rTTQBcuky0 OYZTrhcdITXUx4NpHv1iBNDcAuk8qNegeEP+OY3wIfeCE778yxScX4kuP4zLJ8VX/wkT2CQ3dGP TBjco0DhflFXDoSUiSG3+4E9Ow== X-Google-Smtp-Source: AGHT+IFucu0GdldQn4ABKa+alijv3j8VYtPBDwFxyjp/5RaR/PiQlGQL+p3mcrdl7GW8mGm9aN4j9w== X-Received: by 2002:a05:6a21:9106:b0:1e0:d36b:ef5e with SMTP id adf61e73a8af0-1e5e0869165mr32263993637.46.1735070942351; Tue, 24 Dec 2024 12:09:02 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 42/72] tcg/optimize: Use fold_masks_zs in fold_sextract Date: Tue, 24 Dec 2024 12:04:51 -0800 Message-ID: <20241224200521.310066-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 4090ffe12c..2d634c8925 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2507,31 +2507,25 @@ static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op) static bool fold_sextract(OptContext *ctx, TCGOp *op) { uint64_t z_mask, s_mask, s_mask_old; + TempOptInfo *t1 = arg_info(op->args[1]); int pos = op->args[2]; int len = op->args[3]; - if (arg_is_const(op->args[1])) { - uint64_t t; - - t = arg_info(op->args[1])->val; - t = sextract64(t, pos, len); - return tcg_opt_gen_movi(ctx, op, op->args[0], t); + if (ti_is_const(t1)) { + return tcg_opt_gen_movi(ctx, op, op->args[0], + sextract64(ti_const_val(t1), pos, len)); } - z_mask = arg_info(op->args[1])->z_mask; - z_mask = sextract64(z_mask, pos, len); - ctx->z_mask = z_mask; - - s_mask_old = arg_info(op->args[1])->s_mask; - s_mask = sextract64(s_mask_old, pos, len); - s_mask |= MAKE_64BIT_MASK(len, 64 - len); - ctx->s_mask = s_mask; + s_mask_old = t1->s_mask; + s_mask = s_mask_old >> pos; + s_mask |= -1ull << (len - 1); if (0 && pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true; } - return fold_masks(ctx, op); + z_mask = sextract64(t1->z_mask, pos, len); + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_shift(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 187BEE7718D for ; Tue, 24 Dec 2024 20:13:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDY-000721-CP; Tue, 24 Dec 2024 15:09:24 -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 1tQBDH-0005t9-GX for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:08 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDE-0002vK-LN for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:06 -0500 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2efb17478adso5478252a91.1 for ; Tue, 24 Dec 2024 12:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070943; x=1735675743; 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=iOuFCqy4nAJ5B7qZ12n5+XuPYo2SCzX8rn+oDAFQ9fE=; b=oN17Czdvk9dIPVV0jH99tNlm2bltHi20tbFnT92jSnuvEdyMsuTgT5GHOZ8ffOjS0Z zKfnvNqdFKIL0Jpvii8dEpyNT06d0c4otsyFWDsm4BUTtoLM9eFB9cAx/X51eMcyPpz/ ueNJ8f4bJII+C57gw+oaRjkUWyFFknPCQloxIF+vVqzWQh0T2xJWEDds+xiMpMjscvyi gCizhItnwmxRs80qu1vuT1uHKJdn3mBZrJ3wt2TdX6OKvKUCajGziExo/RMVQOxcZCly 5dYEsx0JVodTQSjsdwlhrP+XWntY/9a56APAleqgfKSzcw8JM+vDlsESbCOiiDSd44t3 5PnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070943; x=1735675743; 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=iOuFCqy4nAJ5B7qZ12n5+XuPYo2SCzX8rn+oDAFQ9fE=; b=Ptwr3+kesQO0oQxoEV6ZeNGJMosYOjrlKlGy/7beZb40EM8kDXhO+o3HB69e9sqfVW X9Rj7xUifKyJegJhYw+lfGczBrSmziP0ofz1t3TV6WUaasg1kHggfukkkGRy1rXsQLv6 rgmRr+0GqREBNNlMCXDT244AhRM7G03v8sv4nK6VKkb7MRHsox6iLmFXlNPkT05c7Od+ E4GyQnR/2Wwy1tmkBYpjvSMtAv6zOWF7kEztXNUULW5nfxLN3HBoyyRr561me5NZHp+e 4c9jrpOSrMwKsX6Sd8qO+bdQ7GiCGVtudTW0NPg0dRYe06mzbJT6SpgOMHkankXt4kSX 41Jw== X-Gm-Message-State: AOJu0Yz2Oc7d0JmxtJygW+Y75AlWPgh1qEzpvwJfOHULxxbP8zXWKQwo I2E1U/lbf5jqnF9P3wPKYojYV27XPg1EfxCeoHHa91d8KdQAEOt/J42wuF+t+da2h0xPlJn4a7v G6Ec= X-Gm-Gg: ASbGncsPQL4fbwO+YTDyqq72CjnQIH2inAN192c6vHFpdp6YG2p+hKJpgZWb3tBn2Ff dJTsYWcf419eaE74/uzm3QyrzOeM/vkuPdRNeW8COk0g2vpjyPFoUubHaU9A85pCzMIuiQfIAHx uzRpY1CqE9PDhIP4TBoI3LLMu1scrQPsD3utkKcehwLwi/Xd02Q/HffM+d6tMN21+BSdqYS1HJr qiO70FlbZB3TFXNoKykGmx3EFR/OFzgHkEa80xOSAzaIEwBAYt+id6ESjMf2QMGW9R++LPEcXxz EJomaIVTW4HQmNnIN8GFodKAaw== X-Google-Smtp-Source: AGHT+IHQNF3i7h50mK1Ol9vCvKhTO2wEE90FwV+BKW5JMFnczqvgQpk8q/C+pwSsNP34/Cgzag+JrA== X-Received: by 2002:a05:6a00:3c84:b0:725:4615:a778 with SMTP id d2e1a72fcca58-72abdd7a148mr20442194b3a.7.1735070943279; Tue, 24 Dec 2024 12:09:03 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 43/72] tcg/optimize: Use fold_masks_zs, fold_masks_s in fold_shift Date: Tue, 24 Dec 2024 12:04:52 -0800 Message-ID: <20241224200521.310066-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 2d634c8925..b70e9bdaf5 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2531,6 +2531,7 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op) static bool fold_shift(OptContext *ctx, TCGOp *op) { uint64_t s_mask, z_mask, sign; + TempOptInfo *t1, *t2; if (fold_const2(ctx, op) || fold_ix_to_i(ctx, op, 0) || @@ -2538,17 +2539,18 @@ static bool fold_shift(OptContext *ctx, TCGOp *op) return true; } - s_mask = arg_info(op->args[1])->s_mask; - z_mask = arg_info(op->args[1])->z_mask; + t1 = arg_info(op->args[1]); + t2 = arg_info(op->args[2]); + s_mask = t1->s_mask; + z_mask = t1->z_mask; - if (arg_is_const(op->args[2])) { - int sh = arg_info(op->args[2])->val; - - ctx->z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh); + if (ti_is_const(t2)) { + int sh = ti_const_val(t2); + z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh); s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh); - return fold_masks(ctx, op); + return fold_masks_zs(ctx, op, z_mask, s_mask); } switch (op->opc) { @@ -2557,23 +2559,22 @@ static bool fold_shift(OptContext *ctx, TCGOp *op) * Arithmetic right shift will not reduce the number of * input sign repetitions. */ - ctx->s_mask = s_mask; - break; + return fold_masks_s(ctx, op, s_mask); CASE_OP_32_64(shr): /* * If the sign bit is known zero, then logical right shift - * will not reduced the number of input sign repetitions. + * will not reduce the number of input sign repetitions. */ - sign = (s_mask & -s_mask) >> 1; + sign = -s_mask; if (sign && !(z_mask & sign)) { - ctx->s_mask = s_mask; + return fold_masks_s(ctx, op, s_mask); } break; default: break; } - return false; + return finish_folding(ctx, op); } static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 769B8E7718D for ; Tue, 24 Dec 2024 20:18:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDR-00068F-1v; Tue, 24 Dec 2024 15:09:18 -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 1tQBDI-0005zH-Q2 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:09 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDH-0002vV-90 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:08 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2166022c5caso50556375ad.2 for ; Tue, 24 Dec 2024 12:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070944; x=1735675744; 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=fWD89RQ9Sb2UhObXSAa3h+FC5JlParE8myCYhh3ZG/k=; b=Bq1TqnrfhldLnw+FKKsZKyIbN7U4gy5OzmmWatzQiW1CsPK8qltF1bx277PdTFEHEi o7mYtOPCi9ro3+MY88wHSb8W9ZoQIOow0k+if/YdNK9xgsBNNR8w2VlWlZY+4UuAmp8m MX/IzYv/NIpZlRjds9DxjZuLpiES5sbM58dFCYb5BNOElhpNyLytPZHVNRWyB+vYCtvX iDhDTrMYDnLIPNbdMkZLAvFKpfIhscGiiyQ2hNl5exul9QY/DgD3hTbSO98CGHss8ky2 D7SbRd3FJeydqrLe1BD+Nvvo/BPRKXeFEZgEtUSTjhxcQwLbVI8aHV+NGENOd7HyXMzq Ho/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070944; x=1735675744; 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=fWD89RQ9Sb2UhObXSAa3h+FC5JlParE8myCYhh3ZG/k=; b=gt9M/mHhPwpDcv96kCS66V4XwMQiCNQnyzfksDOVlZdSe1CpgbcfxlSfZ0iNAHMW3S Kh1V/wD5wf4AUHHSE360LHJMUx/almn8bliPJ7Pf4j5/rAJEmlLXP9lqlhM3Qb20+wAe kZXRPeqUHQtaSWuDPE2tvmxdkPZPm3ANgw9N8qYBWjkXoZSSFdXXbMeXqGVTRUr4DQ91 0gda4kpZquIqEf3nbuOMmEMO5dHcVhWF49ep6oCpOCCIlz4DpDLVfrbHlQ8mgZbc+4eO Ty/OOt5qTCfOKauTiU6GtbRZusT82FcCEUcyBtdFA0m2dG0G2umOXq++w2+zPI+4glAB ZMfA== X-Gm-Message-State: AOJu0Yz/hyP/In8uSVzGcqqKaZ1VDBMv+1/pHrLLYeHyev91t9QKOf3+ yTJGPwtLYKANdJjveGr9j+5Fvrn0542ns/d1GK+qcXwT4aM4pMCY8qbNjeQN0zqxP87sT3X8+E9 zOUM= X-Gm-Gg: ASbGnctNiaq1UHfD6jbbGe/riazny9FW7Iy6tkipkORPbE6q0aapLIF9z0JvoHCiNt7 sPbaq6ggWI1hVGSgiCMl4AafL2ePDITx1SIeXiClbF6OfjsNtJehbYBRFO56u5UI8P3SEUzHmMO B607r0Jr7V74jukw53vmNuY3uIGhQeQ0OasXDvTDXegskeNSb3VPwjMeJOamY8Ts4J5agLcHNF9 VEYuq5tj95hHK0MLi6FfVUwapS2tKImzGzvgMaIpQaR/00rPiJX57lVEnb6NFXgVjgKt2rslL3Y /yH26JbXEGfWyTmThy61QYmIAA== X-Google-Smtp-Source: AGHT+IHeIDj6GjnsQKtX415MMii3AXMmTCqASTYs1PQrp4Yjb/dRVr2m6CH+haQeQWLhZsjeI3Gb1Q== X-Received: by 2002:a05:6a21:1693:b0:1e0:d89e:f5cc with SMTP id adf61e73a8af0-1e5e04605a0mr28516895637.11.1735070944442; Tue, 24 Dec 2024 12:09:04 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 44/72] tcg/optimize: Simplify sign bit test in fold_shift Date: Tue, 24 Dec 2024 12:04:53 -0800 Message-ID: <20241224200521.310066-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Merge the two conditions, sign != 0 && !(z_mask & sign), by testing ~z_mask & sign. If sign == 0, the logical and will produce false. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index b70e9bdaf5..26790f7c27 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2530,7 +2530,7 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op) static bool fold_shift(OptContext *ctx, TCGOp *op) { - uint64_t s_mask, z_mask, sign; + uint64_t s_mask, z_mask; TempOptInfo *t1, *t2; if (fold_const2(ctx, op) || @@ -2565,8 +2565,7 @@ static bool fold_shift(OptContext *ctx, TCGOp *op) * If the sign bit is known zero, then logical right shift * will not reduce the number of input sign repetitions. */ - sign = -s_mask; - if (sign && !(z_mask & sign)) { + if (~z_mask & -s_mask) { return fold_masks_s(ctx, op, s_mask); } break; From patchwork Tue Dec 24 20:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1EC6E77188 for ; Tue, 24 Dec 2024 20:17:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDT-0006VK-63; Tue, 24 Dec 2024 15:09:19 -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 1tQBDI-0005zI-S9 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:09 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDH-0002ve-9I for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:08 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-21649a7bcdcso57377605ad.1 for ; Tue, 24 Dec 2024 12:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070945; x=1735675745; 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=Fe/KzvBli4+DT+q021rXbUAcleZsNqwpOUiAKLjvzrs=; b=nmiR9B01JES9/PXH1gp0bzCPqexq4Kqc1ov0Ga2iareRJm10owzOa7M01jDGTiIAUJ wdNuRMvzlBL86KwnXAh/cdXMWKJU+vNV+arGLORhIm3jgW0fSUE5TiqAMSptHwBcwqKz UVmZ9Mpq8seX6veRznmM+S5VAnvx84kTsPqg2GzRWbvCqR4mkFyHxjRR8CVkAuu7QhNc DvUfW39luu2Bp9oOC/Og66f8QpPxApfEyWuiRdSe0W8Hl/FGV1d+6kfSGlb3snYKU4Ui bwFOcimtr2tfnueKlA7kag7VFtcciocbG3nAfzgi7NVqWqLiep4MjB+d1EvJNjEhk535 k6gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070945; x=1735675745; 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=Fe/KzvBli4+DT+q021rXbUAcleZsNqwpOUiAKLjvzrs=; b=qTULClORO6zWn4Heo1fCopGCQu9fEQIh0L6tjCCgvVF6NxGOiuW64Sg+Fx+J1g1mvh M/qzdL9++r/2LPxBx76Qa6kZdlp9SiLwMrOgxqyseM4OCYgP5nEEufZoHsCnqPJf0cIv Yv1ee6BNHFD5PKnRX3AblhmqTti4YwQNLsQd1HGvmUCtQsA7TIA6ua3Mg32EYH5wN+QZ kBMcU9/nRhdfVvZdYPcRxXrCEBGYO18GQIFUfW+0c9P7z1OPGVTzGas94mOLinXn1l/B GZdQFVwLt1o8jXA7hsIuV2Ypn42a9w4oJi9niF1MQIdwxP9AL8t7/GHlwZOOBTHOl5fh 4vmg== X-Gm-Message-State: AOJu0YwqgNwYgRhRH4k0VYS5DcQICGGnmAcFE8S1J9a6GuF0ehJmLITa Mr+L31jBKxmRhyxQoo0jomdQhVoinoyXGXyIBT1PD304rHWvd6VIPrDA/+LCDGJsuBhl75AM9rY 4yro= X-Gm-Gg: ASbGnct+VSWrj3A47onc34eBenqX6QtAyX7c68m4nLsw38xnUIvGPHLvIRZo/+S+k9+ SGCGXb1FAkJHSJNeLt4rZjeUms9mCHCwidrSXtkKOlb5TJJ1dD8S+y7YS1T7XGzcH0l3nNgaJss 006bDujkkd9fHAPPHOU8lo8rVx1IoaJsTDpLSzB+HzCO99ugLkbYS7UT2Jv88RjTq6tzp6yAEs/ zC6ORHZh1B+Vmdl1Hei6V9Z5e9pHyQQRY4IOD7Aj5Ky456ArMa9wf84KhM1RO7tT2kU+5wq1y3J Jgvhrgw+inBLcK+M6ITcCnzT4A== X-Google-Smtp-Source: AGHT+IFo+FGuwZbYV9CpYwyRDmSqKwT1oc1uD+5B8CywUIUFEKz2H64Cd2xmeAI3TlFOLo2hlFMlgg== X-Received: by 2002:a05:6a00:3910:b0:725:e37d:cd35 with SMTP id d2e1a72fcca58-72abe060d9fmr25548964b3a.18.1735070945450; Tue, 24 Dec 2024 12:09:05 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 45/72] tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec Date: Tue, 24 Dec 2024 12:04:54 -0800 Message-ID: <20241224200521.310066-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Duplicate fold_sub_vec into fold_sub instead of calling it, now that fold_sub_vec always returns true. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 26790f7c27..cd052a2dbf 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2620,12 +2620,15 @@ static bool fold_sub_vec(OptContext *ctx, TCGOp *op) fold_sub_to_neg(ctx, op)) { return true; } - return false; + return finish_folding(ctx, op); } static bool fold_sub(OptContext *ctx, TCGOp *op) { - if (fold_const2(ctx, op) || fold_sub_vec(ctx, op)) { + if (fold_const2(ctx, op) || + fold_xx_to_i(ctx, op, 0) || + fold_xi_to_x(ctx, op, 0) || + fold_sub_to_neg(ctx, op)) { return true; } @@ -2637,7 +2640,7 @@ static bool fold_sub(OptContext *ctx, TCGOp *op) ? INDEX_op_add_i32 : INDEX_op_add_i64); op->args[2] = arg_new_constant(ctx, -val); } - return false; + return finish_folding(ctx, op); } static bool fold_sub2(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9E2FE77188 for ; Tue, 24 Dec 2024 20:14:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDl-0008Hu-Jy; Tue, 24 Dec 2024 15:09:37 -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 1tQBDK-00060F-Q0 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:11 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDH-0002vi-Me for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:09 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-21628b3fe7dso53767515ad.3 for ; Tue, 24 Dec 2024 12:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070946; x=1735675746; 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=IaOVBhCtGffzz8f2KF+gUKNW0uB05LssizAuZqhSk0o=; b=m62Ut5Zm/lKIFsfrNtU482mx2TIgy6DpzQLEUslYMRMwPZRi1J7BVNG+VTpQ2O3kbZ wF35q24jpWHBsq7hEPbnTlMExzMu51188r6Ew/BYxbhFG6r35BFgKbd4wvOFo8RtVUnH REANyzsxvEK5JoNsPUegl8jGl3veYEiw41wk1V5vr8AtqvdEqDnQxv7kdOFanMD6SMKm c9AreYPcUL7ZTcWTl2rln+b/wTpE0AKvE2ZTWIc+kKfcq7y5L3VHiThJfTXAe2iyX+Y/ 6PIzrhwQiqkeJdeiFuBA8a7IXOKBF8fwrq7WI3tWSdBeVB0UTJ8q9J83QDKGIX4nGt3+ Rkhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070946; x=1735675746; 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=IaOVBhCtGffzz8f2KF+gUKNW0uB05LssizAuZqhSk0o=; b=nuPlFw6u1SxaM8Zp6Ttu0JcuvXP0wRH67LfcUmgJs2uAFddXAaqp/dUWdaBsFxVnMP /G36radPjq1+lu6ablUiOzpxtFHQiRrCmTGrPpEqNcTcBfPxs8ddcP99AQBna6Q1GW58 XvH8MaxP4Z7q0s1iputw+/MGTQ+bFb61p9QIEH+XJgYluNGdptLRk58A04xRBaBwPTrC UV822Rl80uieJSiifbMreiOqV57b5I3GU7j/c6Kfxl55iA54Ej7d6tWoKi+ezvugsSkG /wUWKfRJ/hMxCLukLCIU9w5122CFR7nQzMP6s4xruQmNmN6F1bN2RgHGEH88ReuAQwk2 Ue/w== X-Gm-Message-State: AOJu0Ywadbz2OD2Csqd3obEI8giLRDV+isnaDoLvidtkD+zaqt87zDpc wlgCgxhNwV7q23C4aEBw/6BLtkIl0sctpyPqSop58fJrTBHsNNMEQJY3qQp+mir7cAbw21yO9US YwZs= X-Gm-Gg: ASbGncsqPgnYfUra8q9fQjO+CQ80xW0BwHbpRnpVjOPZGR3aflc9DCSnNy45DmP0Jci OyYpOSOY1rtmQMceBEmVF9HyRg5SYNZyiMPzUv5TeJ3EdBWPDPsIee5v1pIWFqdRLGzmbDE7Sxj Rcs2HvQ2KLkci9KMefacXrhNqQLWds0g0mKWwqtRThZ1I79bttVzqYnprvGBnvy5w1kC40Tpb84 TNibZsT5ggFqqWmlmWdbIWbFnMuk+2cfrzck92N3Kvwh7UQhmWJuM59jJZ/vrIJdeOIa0mRpINe +YEEwFzCPj7B0rAQbT7gztUQ6g== X-Google-Smtp-Source: AGHT+IEJbzMwr7gmQ6l0Sxq0x5Vonl10//ccB8vC5bz+vivVu9lMFC7NbIkcCKw0ENuAS0uUmhPtbg== X-Received: by 2002:a05:6a20:a10b:b0:1d9:aa1:23e3 with SMTP id adf61e73a8af0-1e5e080c43fmr32208483637.32.1735070946442; Tue, 24 Dec 2024 12:09:06 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 46/72] tcg/optimize: Use fold_masks_zs in fold_tcg_ld Date: Tue, 24 Dec 2024 12:04:55 -0800 Message-ID: <20241224200521.310066-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index cd052a2dbf..7141b18496 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2650,30 +2650,32 @@ static bool fold_sub2(OptContext *ctx, TCGOp *op) static bool fold_tcg_ld(OptContext *ctx, TCGOp *op) { + uint64_t z_mask = -1, s_mask = 0; + /* We can't do any folding with a load, but we can record bits. */ switch (op->opc) { CASE_OP_32_64(ld8s): - ctx->s_mask = MAKE_64BIT_MASK(8, 56); + s_mask = INT8_MIN; break; CASE_OP_32_64(ld8u): - ctx->z_mask = MAKE_64BIT_MASK(0, 8); + z_mask = MAKE_64BIT_MASK(0, 8); break; CASE_OP_32_64(ld16s): - ctx->s_mask = MAKE_64BIT_MASK(16, 48); + s_mask = INT16_MIN; break; CASE_OP_32_64(ld16u): - ctx->z_mask = MAKE_64BIT_MASK(0, 16); + z_mask = MAKE_64BIT_MASK(0, 16); break; case INDEX_op_ld32s_i64: - ctx->s_mask = MAKE_64BIT_MASK(32, 32); + s_mask = INT32_MIN; break; case INDEX_op_ld32u_i64: - ctx->z_mask = MAKE_64BIT_MASK(0, 32); + z_mask = MAKE_64BIT_MASK(0, 32); break; default: g_assert_not_reached(); } - return false; + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_tcg_ld_memcopy(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBB7DE77190 for ; Tue, 24 Dec 2024 20:17:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDo-0000OB-UH; Tue, 24 Dec 2024 15:09:41 -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 1tQBDK-00060G-Pi for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:11 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDI-0002vr-QE for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:10 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2163dc5155fso55566205ad.0 for ; Tue, 24 Dec 2024 12:09:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070947; x=1735675747; 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=CAh6al20AnnURobHcMKk7qN1tHMzvpICfK2iYSPIwVw=; b=A6xGeMchkoYnkaP3ifdjKYDdSQJ1WLSWwdlKINO8iZS09ZWNwRLl5iT9gylIvLIkIc 0mdpYPDsh+Et7IZFpfs2N8Gg7ZCbIg1QSV8u36Y4GoWhuJA9ELgJHVfds4AzzOGhQKKh qf84drDNDU8P3Qd/V9Mqb6FrqCUz3lWrZ591vvfE60cAWOUTP9CAHRpglug0+KLUYiaR meUSjBmmAdlzjCKK6QF5c+45wA/ZaSXOMbWgWE5pKgcl145v7TA+Wu4CPEnp+b2Sy8TR k+Rgls0z5D4YM7LfIoXLIlaT5AageuGkrlaLY+o+M8TNags5SY0KtqH32gLQVuWXQX9n YLhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070947; x=1735675747; 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=CAh6al20AnnURobHcMKk7qN1tHMzvpICfK2iYSPIwVw=; b=UCJ5TCNHWVyJ0UoCbRyppkWzSVT1avtRTtDWfSoJhQ9wYFu7KXZJO7uTqH6XPEI+cH eSgcqqO3Vocy2jez3gGs0fdTgJoU03w0TSQk5Q+PSi+UK4u2ux28O8gf8M8n2h/yPpaV qy/aMDBqzjJPfSqFvK8P8RiwhyA5XWrEImVdiKsUibRpmlWp9n7nWXLIoEUbf79rY9tq 2pg1pQKg+2dHIV776zK2tW5MoKZ7lOHl5b1zoWh5g+Hp+dO+CFSA+9rK+xioroBOKQyC UBn5YzfsZyRWL1QOsqxtoVLniF5bBHlje2Qumoa6onJBRK99BZ7Zk9wNPysf+4kM5CQB UnfA== X-Gm-Message-State: AOJu0YxDnsxn8A2gfVpa9e7u3x3rmLLmeutDNnolSIegajmoy2mX/PRC AtUZB+jSseYBChVSzh6wfoF6odBCmussb5XN88z4LSdTjY7Qb5oa8fylrMF24yqknXSrUIU8dL3 m/R4= X-Gm-Gg: ASbGncukR7g5T5+/W57iFPMpUt8jCmLl7SOj1Y1rjl59Rs2oY/2wsjFWMoMoACsbbm2 gb9fsTyKlVYFOfnylDV83MgsvhUBVhjvCE2Odrx6Dgeu9n4OZ0PCN+AgWXv7xo4FCP2k5Ph1JbL 6lHJ/BzUiqkUXBeVCArQvN9lTAWngpVrg0+1yq0oPL9pr6Npm8BPSEShIyxmhmGv1x1wAZ7PrRM SoVJl1Q7UeNjnXqD1JdM1TI8GBQASRJooUeySIbnEIE4rfEg3xpP9PDIYZeYRqKtmJBPDk/oiRR CbMHf/HjzO48cp40QeBXhMWW4Q== X-Google-Smtp-Source: AGHT+IG0FSLM6zsx7xapweeTCHu+zY+LKUC6GbH/OZX6ZekNklICgvh8GtE8KbWaC2L3Rmuch93VNA== X-Received: by 2002:a05:6a20:c705:b0:1e0:f495:1bd9 with SMTP id adf61e73a8af0-1e5e04503e8mr31192399637.8.1735070947527; Tue, 24 Dec 2024 12:09:07 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 47/72] tcg/optimize: Use finish_folding in fold_tcg_ld_memcopy Date: Tue, 24 Dec 2024 12:04:56 -0800 Message-ID: <20241224200521.310066-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 7141b18496..047cb5a1ee 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2685,7 +2685,7 @@ static bool fold_tcg_ld_memcopy(OptContext *ctx, TCGOp *op) TCGType type; if (op->args[1] != tcgv_ptr_arg(tcg_env)) { - return false; + return finish_folding(ctx, op); } type = ctx->type; From patchwork Tue Dec 24 20:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22A58E77188 for ; Tue, 24 Dec 2024 20:10:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDa-00073O-6Y; Tue, 24 Dec 2024 15:09:26 -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 1tQBDM-00063Q-1J for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:12 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDK-0002wA-BY for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:11 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-216281bc30fso65762265ad.0 for ; Tue, 24 Dec 2024 12:09:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070948; x=1735675748; 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=o97JXDzIrwrMdvgcbM1yV2U/pc+QtaOODWU42ZGI8Z4=; b=X1pJnsc9MweBqFLdkApwORk3nA64ycsiEmkDIbBjiLN8gsD9uQHta5UhVazs2iZhc3 DHmo3haQqmEdT9e1WKSCn/cuiDmG+r27owRSp/8ZoHRRYpv9+/V4aOT2EtFP9E9kZqk4 QArJJMR/kgoz78lteyXTyiepdDsZY4uYwkG3aOllO5wZQvr33kmAIKpjqXKnZcx37TQm fkuYsybDJVkYturOqRpQMkTqzCEaj6zzjBU+ugWp9j0SWnc5JIqZZbqSFT8Vq6Cdf5yO YhTZJd3IRNXv7WuBrITo8u/KlwX5z83PS5VjsatC0i09Bj2AaZLRaH3AxOMX164q2AT1 m1OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070948; x=1735675748; 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=o97JXDzIrwrMdvgcbM1yV2U/pc+QtaOODWU42ZGI8Z4=; b=avdvZI6ND1LBpW0N9F0CCAf2zX9Rt/E+80zfcYUIVCa8IVjAFtDanB4iGC5SVDm66R UoJ4FxZl6+dZo02bNDMWNlsaxpfNeq3hKKyS045ZxNGYJ92UNWWo3Gyzec8QMPJRlca0 dShqEIEheAz2y8UHNLcBiFcBIwA41jDu1f3z5kZthZAaUSuE03FvBAnV41UsPC0S84G0 YnKQC8o8aSODqWCIWvCGh/I8BhhcJdCMA/5XcBD8c/BZUExe8sjxvSiRgvWBL92/3CJq bYes/bH+1ht9+Va4ZYi1YU3EQUCGwQ7dHc5bmwBQk81685bzJgJLd8xFjM4sPvpYE2f4 L82Q== X-Gm-Message-State: AOJu0YxWCt7CoUl/66Dk+9iXgWrGOwvNHY9qokNQnAJhCC+Eicks79uw 7aYaXWQchanmJ5Xir5w0Y3eZLyTSelgi0H9wF1xonsVUWYFRwnkRivZT4SV77D3Iq2kiaUhXK/B Hv2E= X-Gm-Gg: ASbGncvEhSJ3VOv/fMTB/Aoti+2ti46674SauEGWAuPOV6GTKH9rpbhUV2UQVVAIccf dqBcfIOwBS5xqfRXGSpyP3WpWPSvrIBD59ZSnlaq3hII930D1cTd/Cv391RZina0NJgtznfg7EA NSV58k2EzF2Vl3wKgWS7Vj/gDwLucyvZ7rHY7es4kr61dwkKmy0RN0yjecz3eB5JV0xiQnCMpb6 0cZs3TJZW4EjfrzRlXXnoxPbn11eCVnmB4yGRmkz9L1H9+TvAVsLnVGxKkha0BfqeTM9zj1zA+4 YH6KRXvgXBkhlEh08TSsWp8fxQ== X-Google-Smtp-Source: AGHT+IGgDFMjTqHTRGd1f7T9w9Lf7XJr0owOzZitubGmOivmttyb4YuzdB+QrrhNaU+xifIgbKYpXQ== X-Received: by 2002:a05:6a20:1596:b0:1db:e0d7:675c with SMTP id adf61e73a8af0-1e5e045a0b9mr30625360637.13.1735070948607; Tue, 24 Dec 2024 12:09:08 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 48/72] tcg/optimize: Use fold_masks_zs in fold_xor Date: Tue, 24 Dec 2024 12:04:57 -0800 Message-ID: <20241224200521.310066-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Avoid the use of the OptContext slots. Find TempOptInfo once. Remove fold_masks as the function becomes unused. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 047cb5a1ee..d543266b8d 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1077,11 +1077,6 @@ static bool fold_masks_s(OptContext *ctx, TCGOp *op, uint64_t s_mask) return fold_masks_zs(ctx, op, -1, s_mask); } -static bool fold_masks(OptContext *ctx, TCGOp *op) -{ - return fold_masks_zs(ctx, op, ctx->z_mask, ctx->s_mask); -} - /* * An "affected" mask bit is 0 if and only if the result is identical * to the first input. Thus if the entire mask is 0, the operation @@ -2769,6 +2764,9 @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op) static bool fold_xor(OptContext *ctx, TCGOp *op) { + uint64_t z_mask, s_mask; + TempOptInfo *t1, *t2; + if (fold_const2_commutative(ctx, op) || fold_xx_to_i(ctx, op, 0) || fold_xi_to_x(ctx, op, 0) || @@ -2776,11 +2774,11 @@ static bool fold_xor(OptContext *ctx, TCGOp *op) return true; } - ctx->z_mask = arg_info(op->args[1])->z_mask - | arg_info(op->args[2])->z_mask; - ctx->s_mask = arg_info(op->args[1])->s_mask - & arg_info(op->args[2])->s_mask; - return fold_masks(ctx, op); + t1 = arg_info(op->args[1]); + t2 = arg_info(op->args[2]); + z_mask = t1->z_mask | t2->z_mask; + s_mask = t1->s_mask & t2->s_mask; + return fold_masks_zs(ctx, op, z_mask, s_mask); } static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op) From patchwork Tue Dec 24 20:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920522 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 792B9E7718D for ; Tue, 24 Dec 2024 20:17:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDp-0000OY-EI; Tue, 24 Dec 2024 15:09:41 -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 1tQBDM-00063m-Cb for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:12 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDK-0002wJ-Vh for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:12 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-216728b1836so49418655ad.0 for ; Tue, 24 Dec 2024 12:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070949; x=1735675749; 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=6T4dE7mQpDnGfqvX4E7RoeAOsu5gIGr+d/C7xqfvwqU=; b=WA7r/kv98jIqIyrR0lXubhAKkPAptY1YtU+ANHVSfUkbfXmqOBa5VojI/oiJ/DvMZy IBjxxnobd3enwmxfKkmbmiBzCEvhMplm4FKdeSKi2mUwqIQjJhqN7CCbFEOsmQ6Gz5Ne D+avwK21PUl2m6DMpjFkbk8HMpId4DChfQdSoKTvnFYsEIpzdO6d3Ydla9W1AUwUA6F0 /Oz9l+GLuXXF9kB7WtF1E+8/bhJqsL9OIzvl/vzcqmN7QwuO1OgeZlvwKGBMrSbov66V swHkLOUZdDB+ObtZvbPgxZpXSra4zipIw0mZ3/vbrnRbklU7h2ds8RmFdMOkUsk7m2XX o+Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070949; x=1735675749; 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=6T4dE7mQpDnGfqvX4E7RoeAOsu5gIGr+d/C7xqfvwqU=; b=pEcXuhoc2luTkCe8jy8GwmqTospgCbzMP9RXhRvgVfs7pY7iOKKwdQTs5H9v/k6LLr UT/L0zatTOt8K3GOi/QWJ/mSbYag6YF+K4c4T0myA9GpBZ8DQMZyClAtucctCzJx+Mym stgbL3au8mP41Ah/QXUzyFft0e1Tm+S88sW2ESVR205oT3FWQPsWHtkLiMMec8JDp2/Z /Cun2TogbhuN3+rAB5ZHHFPCXMWO7uWpTn7c+u3a4Wr5XgAybOYaU7TLcU8jjNo0BeUz KfP0f/YiLJEjNlO0Rw+D7OShviHMzgy6lLFdc+Vuyo1GqXjEXe1qqlJ1U+e6l0RDOZQv kk8Q== X-Gm-Message-State: AOJu0YwD0bu2TpECMifLO09umwZC51xgLRGpPfJU6vUs66P+wUd8EryH YPWtVLdazIqddrEt9YIQaiLD59OrP2J2PqqHfplk7oAbXGe6eYDeQx5QTbDE/RXtVFwffjnkDa2 95B4= X-Gm-Gg: ASbGncvdZXjgj0Q0McSmHUILILseZquzdffgZWk73sLG+Dq2ddyfmpQO/ofnyC/Dqrw uZ0imfmKfN1+7ufapNrbXeGeV+hgxEI28con0JaUtOs5jouNG7DzdxLuLkUm8qa4AodyzZ71q8A O/DMMAVPpWTh7fgas9WgtmJsXelVoUPTHIHobJ2R6EbQWFqIum+93+1kdNlEL8LVwYjw1yIgixt b5hT2QVxpp794F+EoOxa6rNjbSqm9XcIFYEuN1Hg7IMsoqtBb86fvuLK5dlqquH88QfsisTrP2c OJTQril4LWYmFPZM+LuVheUWWg== X-Google-Smtp-Source: AGHT+IEtQdXCZNho2AFaueBaqoZzg/SSoGPNShyclq/I7z5ze6tvWOhrOlJENfvRT94/O9jPeHa/Ag== X-Received: by 2002:a05:6a00:1144:b0:729:597:4f97 with SMTP id d2e1a72fcca58-72abde828c1mr28376953b3a.20.1735070949616; Tue, 24 Dec 2024 12:09:09 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 49/72] tcg/optimize: Use finish_folding in fold_bitsel_vec Date: Tue, 24 Dec 2024 12:04:58 -0800 Message-ID: <20241224200521.310066-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index d543266b8d..4271d14d2c 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2833,7 +2833,7 @@ static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op) return fold_orc(ctx, op); } } - return false; + return finish_folding(ctx, op); } /* Propagate constants and copies, fold constant expressions. */ From patchwork Tue Dec 24 20:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B55CE77188 for ; Tue, 24 Dec 2024 20:18:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDd-0007Na-Pp; Tue, 24 Dec 2024 15:09:29 -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 1tQBDN-00065t-7t for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:14 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDL-0002wW-Ob for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:13 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21644e6140cso59073775ad.1 for ; Tue, 24 Dec 2024 12:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070950; x=1735675750; 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=NoS6fF+zYBIciWuFVqUakribBmIpxW8sJFwdLDnjnLM=; b=hHDaFsZnSIG3RwsIImP/mb1KE6Go6dQQQBvAbbVj9QN7HHrv/ssXPHX8lrltBZgwVg p6t6dxPvYYcLGnsrKGco4D4OlQUAdt3zSMysC2yo+9PjuCYU/azYxNjEMfGUhaF/gJtn /xe4jq7/7KOaKvSy0uVLJ8RsBuQQOvwnmMGPtedkcqYgjt+YplQwfjV5+KC0GNAvgm4Z J9Ky+rSV89HWTdoJaNf7lor0XkklFRYNuS72XYHDPAVfHVC2ku//YxpUFbCcWWr1oF4u Nl9yWIpfJxSnK+7idTfsWUkA3Kfo9PqNRGPj/qjowkN+uSdByrw1q4u/Nc/tITiepYqM cBjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070950; x=1735675750; 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=NoS6fF+zYBIciWuFVqUakribBmIpxW8sJFwdLDnjnLM=; b=EclfKCQXv7D3nA8e8XB4tLukVei4IDvxL86geXOazMpqldHNaCSaKLS3ws/ldPiYII D/xF1cDizFFf2A2NVIyE7b5I9VjFgkqlEz4amEyk+IVI8IkN4AAiPeU/htswthnVr/BP VK9KvAB8HIyaBzGYHLi+Lmb9FdEy/audteJdo0vzfS2VfV7Pvp1aZb38HztbMkbpSFb9 OthFy7Dj7tquaJVpZN1MWXIadwdrha9IqAzbJygszYkofSjxPuzX42dxzTVsrXJCu1BS IUpcFFnAOHtZPSPt6nnF0VDZD/FBSI2LDZomehynIdynnlIcFuheyAliC5Y6srfp15AC a+qA== X-Gm-Message-State: AOJu0YwM+3zT00MM5ixtXRnU8u/clpDynJxoy/3W4v+yHDgJr6/L9No+ qHVCiNlrBH1M48C45/oogG/JvHqx7fFMsfrB0F+LqGx39kdi+xxvzR5p9vzEMQ8qWeK/6KFarwf 7KkY= X-Gm-Gg: ASbGncs0nIe/hJl8WmO/qIvRUC0hP6Tb2pYpXwA/JRnVB23VhbCFJ84CV690/nM8pRX /v3SuV2JIxRszs0V5GJ6Qw0JWAQqCRfSM7i1qKKDph6UUwedV4aELGrN4K8L9ols3qTRN9DmCXk Zx4iVObdthE1PM372CvvakHZer50cYES+0Xh1ypTWzkcuzURtEtTTEjgQgLLqq5CIZyuDrQN/Xz TSVmVzwkD51e7W1llc3QUGm35H8K5WagqkpK36cm64XSAPjBljMbF+MBvmUQD0Pb671HMtVCdFr UhsOegc9AvL4qCCKTIi/kDYxaQ== X-Google-Smtp-Source: AGHT+IEWMJfN8ElHEHoZyIpi/XwOcIxp5CAYobXPXWITvUbQIHJwGOJwM+4rNsu1jjKq238HfJomSQ== X-Received: by 2002:a05:6a20:9185:b0:1e5:7db5:d6e7 with SMTP id adf61e73a8af0-1e5e083f019mr35018185637.46.1735070950563; Tue, 24 Dec 2024 12:09:10 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 50/72] tcg/optimize: Use finish_folding as default in tcg_optimize Date: Tue, 24 Dec 2024 12:04:59 -0800 Message-ID: <20241224200521.310066-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All non-default cases now finish folding within each function. Do the same with the default case and assert it is done after. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 4271d14d2c..51cfcb15d2 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -3096,11 +3096,9 @@ void tcg_optimize(TCGContext *s) done = true; break; default: + done = finish_folding(&ctx, op); break; } - - if (!done) { - finish_folding(&ctx, op); - } + tcg_debug_assert(done); } } From patchwork Tue Dec 24 20:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920524 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18D71E77188 for ; Tue, 24 Dec 2024 20:18:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBE1-00025n-V5; Tue, 24 Dec 2024 15:09:54 -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 1tQBDO-00068D-EL for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:14 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDM-0002wl-Pu for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:14 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2162c0f6a39so64890985ad.0 for ; Tue, 24 Dec 2024 12:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070951; x=1735675751; 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=+fPgLDQ23uWllVbCL/m78hDFOj9j1qZde0rBMxog4xg=; b=eVZOz8ayP3P+S9SGhNNn3g92F7bj3Awi/rm6h3036jvWdl5UBZ4hes7bQ/gZdBNopN 4kxnl41VbW3mDn29LF4nOHe8qeft6d/HAzkfq97gZGq8yK6x7WNQhC1uzPZ3L+VqUYYC zOSiYe3VqZVopViJKzhdEo0NQaMdHJuXKpZ66+BlmYsy7QiJMeHBNyHvredF5BBgQnol q7i0Suk2qVK2Et9MNJjS5FPU4zvgJ1EDOFm0vTz4Pq9Ky24A7r7UnMKt1jbqxFUWBmNn OcP3x03Ca2Qw7eEvVxN+jbrO33/bSacyB2n1XVFK7zMcx/QFzD8tRjDAFAnjaByrJQPR 1MAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070951; x=1735675751; 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=+fPgLDQ23uWllVbCL/m78hDFOj9j1qZde0rBMxog4xg=; b=td7vfqMZmydzk4GyatNpljtMiNtRIW/4n4/lPnjIJqYCPqUWFtHge+QuhXgDrmNCHb K6t1RTU5B31SF4TsAwHwXrj17jVVAapuWv81mJoxQhFLWmxr4OjYgPms3pV/nMk7kbYE s2uBeEPKqls+EFt+ubUGKnIQnA4SkSiLb4QoumgGhqZFrrT8rzxooudn3RA/ypatO7Vi 9i0bji50Y2Cmkg0/XRyx8t2+kBvxQAg+K/giRXr+ZFduF87xz1liCtj82yFQAwImawEp LuZ11viiubDiJ0gu1rPnZR1lmVuIYp7xU+PsVuxIzxxfPP2YRjLZmDZ47b5O3hGU9PHN iSYA== X-Gm-Message-State: AOJu0Yx8SqcqmnML3950GiOWyiyh8AYewjZzjWtiYxhwfBUYTkegLrqU Ub63Lc4PdQGuMYPVPZVBe+pXrlbMJoORt9n5lGEsgJ8Sx7jINPgcTeDC4TXpzdPFz99HgSWXNuC HsmU= X-Gm-Gg: ASbGncsy6ACh9u3Y4p6E02CgkYujc5obh3SjAoJOA+0Kv1ZY7MXGFnEcoAi3ZAQAnSr BfMjDn1nmEeZq1JJzyX6jsYHMBQKtl9AAAVdLb+ZODtCST9DAR+yospgsr83z+pwPTUIyuc1B50 qEgaQBDpaTPeIhcASm8MuiZXZUnuxQ2DG3BceaYbWwmBBJV0ER6PuQUIwIUKCeTlKg0cxtyknPZ JEbnK/FxCLmkjUOMVXG3SAy73jjSvjc/k+5gLvzCnN9qm+oedsMwRbtCtn1GrJ3kGNSqbuEUkGC rj5gCSjKzyUN9xAKDBQlp/c0iQ== X-Google-Smtp-Source: AGHT+IE4I3sn2Kd1wD+ddDkwyR4BSrFAoepUNxkv6NRJancqTj3y4x152NzQONxzUBXKrAsO298rhg== X-Received: by 2002:aa7:88cc:0:b0:72a:a9d9:55ff with SMTP id d2e1a72fcca58-72abdb0170bmr25230924b3a.0.1735070951532; Tue, 24 Dec 2024 12:09:11 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 51/72] tcg/optimize: Remove z_mask, s_mask from OptContext Date: Tue, 24 Dec 2024 12:05:00 -0800 Message-ID: <20241224200521.310066-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All mask setting is now done with parameters via fold_masks_*. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 51cfcb15d2..98b41975af 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -64,8 +64,6 @@ typedef struct OptContext { QSIMPLEQ_HEAD(, MemCopyInfo) mem_free; /* In flight values from optimization. */ - uint64_t z_mask; /* mask bit is 0 iff value bit is 0 */ - uint64_t s_mask; /* mask bit is 1 if value bit matches msb */ TCGType type; } OptContext; @@ -961,13 +959,6 @@ static bool finish_folding(OptContext *ctx, TCGOp *op) for (i = 0; i < nb_oargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); reset_ts(ctx, ts); - /* - * Save the corresponding known-zero/sign bits mask for the - * first output argument (only one supported so far). - */ - if (i == 0) { - ts_info(ts)->z_mask = ctx->z_mask; - } } return true; } @@ -2879,10 +2870,6 @@ void tcg_optimize(TCGContext *s) ctx.type = TCG_TYPE_I32; } - /* Assume all bits affected, no bits known zero, no sign reps. */ - ctx.z_mask = -1; - ctx.s_mask = 0; - /* * Process each opcode. * Sorted alphabetically by opcode as much as possible. From patchwork Tue Dec 24 20:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D6BAE77188 for ; Tue, 24 Dec 2024 20:17:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBE4-0002Up-NR; Tue, 24 Dec 2024 15:09:57 -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 1tQBDP-00069m-52 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:16 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDN-0002ww-IM for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:14 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21669fd5c7cso57808145ad.3 for ; Tue, 24 Dec 2024 12:09:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070952; x=1735675752; 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=sDeZA2lUoCCt2kMhRmtoiUVX1sDRebW38v5tmQ0pqH4=; b=yUnhNVkMCtSbF/42gO4KO70hOaVmjk4EF9oSuSjJgod+W9n9Sta4kjRGFt0LOFeWXf eY39VBCmLi2ue/Q7JR9JI+Qh/ZTIUMxZOLdsmij39XKhrCDiBmA4b7bOrPJvdQE72cZa z6c2x91PkJ55JrFT+ZqIPoZxbsak8PtFvar8Q3r2ZE0jx5LiuT4Az8Q2z2wCFii5MAEi FREQycjyW2RaImUOKP5Jo6RoCE12DmBZhWpTnVJ8m2OIkYDF1oL/2MUYlzKp1+3g7NVm Ww0ATmP8Y8IXTwYsDrEIjUm7z83Jepzpri9BHryP48FbGdHiijHgea0qGt4Bw5BjrJAF LmMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070952; x=1735675752; 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=sDeZA2lUoCCt2kMhRmtoiUVX1sDRebW38v5tmQ0pqH4=; b=s1vbhp1kIwuaT/9lis1HUQrQm8mp8gIyICWkhXtH+21NSabcruamvQWwIQG7gmFCOW lXbBsW+LVj8+5057CdLn5nNu11+DbgSMtrkx1uThd7WfpeweAM5qxUyhODE6cV//imKg puBMuWCXkeGsc2WHti6aGg9V5pAazw0Ch3i4B2J7EnPi7zztE1CtUgJATaSfFgm5xVmY qy0iWMKKmSE+BKgfCkCM9/SUTFkZ+EkQC6/xES7i4qyGGEpb90MFqlm2NAbTCqElLuI8 UbUAN7HQZMD5Jdwmex9H+nv2ryAwZOv3OqDChZDFNNj3lGvOqjRkx2AoJGSaVOyepplG tc4A== X-Gm-Message-State: AOJu0YyKIv3r51rgHqmz/L+VvOTKBCtRQCI16svBr72h+JpioUXqJF1s UCwuBTqEddtkgDLych+Y8BT925pejn8/0ecxPeOrz32vRNZqUUSBoHJVQchmQZ3SZuEoMxI+iK7 Ash0= X-Gm-Gg: ASbGnctx+N1gTCui2xTRQ3mnx93CtUFJMceHFgt8zpcnCctQEekTfV2wLmeWL964M6p sQoYBFmjWkCSkPYnz+tXgh6mlL5JIvtebWO+/e1FYOv4shaZ0x8RGCsjUcinOIqWYfVk+No0F+S ++x9sbyiAUjd+LlIHnZGMTykoxvvAvBxjaWzGAUsRJz02xYyfnf8wgNm6DRWrG48UJ5BBK+zfk3 FGUv/MZe02Xzbz19Fr4Cdkg5NpXvwzDYqiAZhXsGmr+8pHZwbA/CkKZEFjH6W89UIvL1e0Gdfb+ 1vxZzjZG4c54C8Vw5b1uHEf7iQ== X-Google-Smtp-Source: AGHT+IFAdFm5yZsqESswZrfkxhtBhi4cg607Z2CxV3/pKsLS7dawYP2FKeE9VbRJUOY9TaoXzDKeZg== X-Received: by 2002:a05:6a20:e68b:b0:1d9:2b51:3ccd with SMTP id adf61e73a8af0-1e5e044536fmr29456744637.7.1735070952378; Tue, 24 Dec 2024 12:09:12 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 52/72] tcg/optimize: Re-enable sign-mask optimizations Date: Tue, 24 Dec 2024 12:05:01 -0800 Message-ID: <20241224200521.310066-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All instances of s_mask have been converted to the new representation. We can now re-enable usage. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 98b41975af..182be7e63c 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1797,7 +1797,7 @@ static bool fold_exts(OptContext *ctx, TCGOp *op) g_assert_not_reached(); } - if (0 && !type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { + if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true; } @@ -2506,7 +2506,7 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op) s_mask = s_mask_old >> pos; s_mask |= -1ull << (len - 1); - if (0 && pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { + if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) { return true; } From patchwork Tue Dec 24 20:05:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47891E77188 for ; Tue, 24 Dec 2024 20:11:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDY-000736-OL; Tue, 24 Dec 2024 15:09:25 -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 1tQBDQ-0006SZ-DJ for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:16 -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 1tQBDO-0002xA-Mw for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:16 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-219f8263ae0so23718105ad.0 for ; Tue, 24 Dec 2024 12:09:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070953; x=1735675753; 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=JVk+VUZFNdsgvGVfECPDzgCPxhi/YGH65zoztjt+K/8=; b=em3+DBNIE8dSsSC2fg5T/psu7wO10DQPf7W9/QZMBhgb9zCiP+H8bXp4xut1ong3zX +U37iAg2NqDJFm+n8JSdRgqFqfAo9RQl8YFInuPoiefBl1bzr4kE/KjStfbhzDcw15PF 7Of9RhUEIUKR3lIiFfttogXPzK0byMecGwvdo7fZg4JVSNDb6fqHwMIslYl7sTT3V3xI ZOzTPRGcdEEUMCBGL79o7+8zJqujw4k9VeBTJ8XJyiPv5YForRN8cTP5SSnPrp0e6E+R QaNl/fzE0+9fFbIN8Z++iedTkCojNeFX5P4c59F+BXl3nfYl7V1ms7Jr6EaiR3goflN7 tuHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070953; x=1735675753; 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=JVk+VUZFNdsgvGVfECPDzgCPxhi/YGH65zoztjt+K/8=; b=Q+t6J+QTpzWVnliQ+SriOvlifgu2IEAp+xRl63GoxPVVKr75j3NfxFNhd9s/3y+Uzm Ve5j00pj56Opq0Bs4/6KOZDcbo7sAYnIlww6TBKGr8SOS9gOiphIniqpgRhu3YWAy7jp CRwN5GlT9ats0TgoVbCmvV+kM6TvOrN63kAunWsk83t1IYIhYrfLCP1ogcQ7XaTG7h6P i3PMSFyyxcs35UxOAGu0gskHyjU6M1P0gu9jwH6FwazheRKJKP1uiwi8TdjwCUfg22AX UzN9+UP30o54ILYBy2t/PiFsZXzvs2savdXBWdePmBarKoszBr6QLUqdLw6KsFBL2X9l V92Q== X-Gm-Message-State: AOJu0YxrFPq/RtOKwhMA9CVHIDcqEoqgDVjou/ADfuXiEYKBP4TSQA3c TathsUz5jbbJeu2PRoYRgMzWlUJe3bAaYQqppRoqLq757Ud1NyYsMT3RlFGVTWQSISf/212KYbB S+NU= X-Gm-Gg: ASbGnctzicaGlKvFzb5PW4BVIwL9tM4gKSKAOXbd9Y45X3uG8pCIYLvwtghkKO2M0rn 9NqB6NoNCJ1DDCT+82lha5l/bgK617Xo4Q+jqz/NpqwuFpbt1o+ANXeQOh0nPtIJqsaTHWe183F erTC4ZrTRfhn96SyIiT26rT3Ty0q42Guc5Z3JnMMFNsWUedVEDCnn9wpRCnPFH1vE4jOHHc0/Q7 oEb9hMZgwk/2XklQJOowWaPii6StHEcps2CGpmKVnBlJWR2ll+BbjalrKMfCwzueFWkoSjBaWis BgPLJTdcErDuSpuaZHjxy3dAXA== X-Google-Smtp-Source: AGHT+IHYWWLx/2Q2CBVyh8pKkd+IbXEq1RSw/0FztlYrl2vxyVfqskhzViQPLZz7fkN0UTnPGcQ2Iw== X-Received: by 2002:a05:6a00:6f0b:b0:725:b4f7:378e with SMTP id d2e1a72fcca58-72abdbe0cb5mr23205064b3a.0.1735070953400; Tue, 24 Dec 2024 12:09:13 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 53/72] tcg/optimize: Move fold_bitsel_vec into alphabetic sort Date: Tue, 24 Dec 2024 12:05:02 -0800 Message-ID: <20241224200521.310066-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The big comment just above says functions should be sorted. Add forward declarations as needed. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 114 +++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 182be7e63c..1df61378ea 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1193,6 +1193,10 @@ static bool fold_xx_to_x(OptContext *ctx, TCGOp *op) * 3) those that produce information about the result value. */ +static bool fold_or(OptContext *ctx, TCGOp *op); +static bool fold_orc(OptContext *ctx, TCGOp *op); +static bool fold_xor(OptContext *ctx, TCGOp *op); + static bool fold_add(OptContext *ctx, TCGOp *op) { if (fold_const2_commutative(ctx, op) || @@ -1356,6 +1360,61 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) return fold_masks_zs(ctx, op, z_mask, s_mask); } +static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op) +{ + /* If true and false values are the same, eliminate the cmp. */ + if (args_are_copies(op->args[2], op->args[3])) { + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]); + } + + if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { + uint64_t tv = arg_info(op->args[2])->val; + uint64_t fv = arg_info(op->args[3])->val; + + if (tv == -1 && fv == 0) { + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); + } + if (tv == 0 && fv == -1) { + if (TCG_TARGET_HAS_not_vec) { + op->opc = INDEX_op_not_vec; + return fold_not(ctx, op); + } else { + op->opc = INDEX_op_xor_vec; + op->args[2] = arg_new_constant(ctx, -1); + return fold_xor(ctx, op); + } + } + } + if (arg_is_const(op->args[2])) { + uint64_t tv = arg_info(op->args[2])->val; + if (tv == -1) { + op->opc = INDEX_op_or_vec; + op->args[2] = op->args[3]; + return fold_or(ctx, op); + } + if (tv == 0 && TCG_TARGET_HAS_andc_vec) { + op->opc = INDEX_op_andc_vec; + op->args[2] = op->args[1]; + op->args[1] = op->args[3]; + return fold_andc(ctx, op); + } + } + if (arg_is_const(op->args[3])) { + uint64_t fv = arg_info(op->args[3])->val; + if (fv == 0) { + op->opc = INDEX_op_and_vec; + return fold_and(ctx, op); + } + if (fv == -1 && TCG_TARGET_HAS_orc_vec) { + op->opc = INDEX_op_orc_vec; + op->args[2] = op->args[1]; + op->args[1] = op->args[3]; + return fold_orc(ctx, op); + } + } + return finish_folding(ctx, op); +} + static bool fold_brcond(OptContext *ctx, TCGOp *op) { int i = do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[0], @@ -2772,61 +2831,6 @@ static bool fold_xor(OptContext *ctx, TCGOp *op) return fold_masks_zs(ctx, op, z_mask, s_mask); } -static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op) -{ - /* If true and false values are the same, eliminate the cmp. */ - if (args_are_copies(op->args[2], op->args[3])) { - return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]); - } - - if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { - uint64_t tv = arg_info(op->args[2])->val; - uint64_t fv = arg_info(op->args[3])->val; - - if (tv == -1 && fv == 0) { - return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); - } - if (tv == 0 && fv == -1) { - if (TCG_TARGET_HAS_not_vec) { - op->opc = INDEX_op_not_vec; - return fold_not(ctx, op); - } else { - op->opc = INDEX_op_xor_vec; - op->args[2] = arg_new_constant(ctx, -1); - return fold_xor(ctx, op); - } - } - } - if (arg_is_const(op->args[2])) { - uint64_t tv = arg_info(op->args[2])->val; - if (tv == -1) { - op->opc = INDEX_op_or_vec; - op->args[2] = op->args[3]; - return fold_or(ctx, op); - } - if (tv == 0 && TCG_TARGET_HAS_andc_vec) { - op->opc = INDEX_op_andc_vec; - op->args[2] = op->args[1]; - op->args[1] = op->args[3]; - return fold_andc(ctx, op); - } - } - if (arg_is_const(op->args[3])) { - uint64_t fv = arg_info(op->args[3])->val; - if (fv == 0) { - op->opc = INDEX_op_and_vec; - return fold_and(ctx, op); - } - if (fv == -1 && TCG_TARGET_HAS_orc_vec) { - op->opc = INDEX_op_orc_vec; - op->args[2] = op->args[1]; - op->args[1] = op->args[3]; - return fold_orc(ctx, op); - } - } - return finish_folding(ctx, op); -} - /* Propagate constants and copies, fold constant expressions. */ void tcg_optimize(TCGContext *s) { From patchwork Tue Dec 24 20:05:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 722B5E77188 for ; Tue, 24 Dec 2024 20:18:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDd-0007NF-DX; Tue, 24 Dec 2024 15:09:29 -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 1tQBDS-0006TT-BL for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:18 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDP-0002xX-Mv for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:17 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2166f1e589cso67084455ad.3 for ; Tue, 24 Dec 2024 12:09:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070954; x=1735675754; 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=GEYI0S30T/rgONrSP0b+foHB4bUKaiqwurHUBqbuKQI=; b=RXZkV9sRHT42gj/VRnKru6Qf02UPCljzVnTYOE6qos61gmbFiBQC7frxRhNygT+iYX rk8lrhDS6lgFI/v18NJT3KBZQDzUVI1TvaR3BzQG9TuHLQ7/bQOCQqAxJtAXZiYxPME9 aD7+F+Fwoj+UEehTLCcSbpxJ8Dd29fXwCXRGMvzaTDxjB6SV1+MvVhLwO+Y6dJJfZRjA w7OiGXyYFKzD9vrFMZISn4G5xpVElU/eEKzN24y6DPdKn7Pc+FIYgYrPW2K0yEyz45mB YjYqrvmGrMedHj1/k8/qMoTfXJlbZjMiUazX6buri2qAKWqXxsErodmU48wM/nt6b51b cSYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070954; x=1735675754; 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=GEYI0S30T/rgONrSP0b+foHB4bUKaiqwurHUBqbuKQI=; b=YAA/DJFMUv0+OtKghBMM0PsElJt1GtpjYgJymhfcN5L90lnL1LZK1/5FIA/VEiL8v1 f+Wi9jstWjmciYerYBY4V6ZJICElfwbIo/GTaLNXd88ww9d7FbOzKdmiyrpBTrmZS8Ub 2LZXbhfq6FlES6wIyx4fbRnpPoO9nd7lVBuG5VM6Tv2LqACAbJRhvjzX1HYv90KDpkuN bN+Jg1zZzHvfgw+hV8R9B9YEKAB/UaQ+NUPBH09rvF81YnwAPepnrWIQxySz/KVucMbC hTjnCoqbrxypgJHqRNRbbIEZZRvxVXkPMZelKM+/V8jEAmM6vEZVHpbaoWkqonoBKJOt ZgBA== X-Gm-Message-State: AOJu0YxzKexQ7ZRm6Vnw1kyjISlgqotyqqMMtylPROvousfL/Ze8VBh+ x85xbZZy3WUsbzurjHknBjOlvFCSE7yBkbHlq2WCLxSnZOt3IxX8uufWmXZN6RgdHM9d73elkB4 djKA= X-Gm-Gg: ASbGncvyjimFdDm3KF99j6ikXnuKwOQj5f8bnfyAwbwysyMxvTDL1gcKV2RYCUa5E9P Kz9BQEoqd7xK54F/yW7NcXQlKyTPQgPMKHZhxdTfvokLWqhtJq8U7aV4DvS6xz+ZUgCWu/HwvCR 9r1zoxx9gRvEU7HMGnFORMURYmqPSTbR338VwK/oSjo3P1/X1ckk9hjht9jsUTPCwZlrm4aGQ4Z HACdkjD9TcQJzpD+nm6Yc0Md/jSpBW1Oq/va8R7E6LEP3k7/T5ihiX18JRSoGiNo9dL6xOIxqfW rP0NBZ7eTGUupnwFmzDkwdyAcw== X-Google-Smtp-Source: AGHT+IFzIWlVkuDjWbDwthvcGSWvtRFMgtm4Z8h7UpHcq7nxEYUUICTXWYZn+vH5g1s8lUuFruys2Q== X-Received: by 2002:a05:6a20:a108:b0:1e1:9bc1:6d6d with SMTP id adf61e73a8af0-1e5e07ee6e4mr35782718637.31.1735070954398; Tue, 24 Dec 2024 12:09:14 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier Subject: [PULL 54/72] tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort Date: Tue, 24 Dec 2024 12:05:03 -0800 Message-ID: <20241224200521.310066-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The big comment just above says functions should be sorted. Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- tcg/optimize.c | 60 +++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 1df61378ea..c23f0d1392 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1619,6 +1619,36 @@ static bool fold_call(OptContext *ctx, TCGOp *op) return true; } +static bool fold_cmp_vec(OptContext *ctx, TCGOp *op) +{ + /* Canonicalize the comparison to put immediate second. */ + if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { + op->args[3] = tcg_swap_cond(op->args[3]); + } + return finish_folding(ctx, op); +} + +static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op) +{ + /* If true and false values are the same, eliminate the cmp. */ + if (args_are_copies(op->args[3], op->args[4])) { + return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]); + } + + /* Canonicalize the comparison to put immediate second. */ + if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { + op->args[5] = tcg_swap_cond(op->args[5]); + } + /* + * Canonicalize the "false" input reg to match the destination, + * so that the tcg backend can implement "move if true". + */ + if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { + op->args[5] = tcg_invert_cond(op->args[5]); + } + return finish_folding(ctx, op); +} + static bool fold_count_zeros(OptContext *ctx, TCGOp *op) { uint64_t z_mask, s_mask; @@ -2519,36 +2549,6 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) return tcg_opt_gen_movi(ctx, op, op->args[0], i); } -static bool fold_cmp_vec(OptContext *ctx, TCGOp *op) -{ - /* Canonicalize the comparison to put immediate second. */ - if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { - op->args[3] = tcg_swap_cond(op->args[3]); - } - return finish_folding(ctx, op); -} - -static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op) -{ - /* If true and false values are the same, eliminate the cmp. */ - if (args_are_copies(op->args[3], op->args[4])) { - return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]); - } - - /* Canonicalize the comparison to put immediate second. */ - if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { - op->args[5] = tcg_swap_cond(op->args[5]); - } - /* - * Canonicalize the "false" input reg to match the destination, - * so that the tcg backend can implement "move if true". - */ - if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { - op->args[5] = tcg_invert_cond(op->args[5]); - } - return finish_folding(ctx, op); -} - static bool fold_sextract(OptContext *ctx, TCGOp *op) { uint64_t z_mask, s_mask, s_mask_old; From patchwork Tue Dec 24 20:05:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82D9FE77188 for ; Tue, 24 Dec 2024 20:10:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDh-0007WE-NJ; Tue, 24 Dec 2024 15:09:34 -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 1tQBDS-0006VJ-QI for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:19 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDQ-0002xl-Gr for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:18 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-218c8aca5f1so66390165ad.0 for ; Tue, 24 Dec 2024 12:09:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070955; x=1735675755; 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=2h6+tcbi8+WeC6r2ZX/7AWbF2bUA4Qz417vf0HVpGMk=; b=eKp1ZJIsaCNQGVsAeO/URs1kjwHaqriTb4HZMZuLoMGq3JcYxX6NESaJml6XasViJW GtJmaH2Cb8Z/bKPpxHKEEv0/sFlmGZzIQVzjOhsrcbCUIMqqEIxkSWzRUYcLTDx6gUx2 SqWqJz1DWecXzuWgBsdScZad0XhCtTyc0D1vJxowRY9IbJ7X5wTJFaAnxElMsWma2kji mCi20phimMUZxIjKc9X6QRH6SPIlzdMtL3qBCsN0mW++HHbcPxBp9O9zvYnUJPpYQIQ6 Eyy4ay21sX7jBF7dhWU1Gl3wCLqY/mKIndhx1iXEiRUvYJnA79bUnK92Oh/bKdNSi1Kz v3Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070955; x=1735675755; 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=2h6+tcbi8+WeC6r2ZX/7AWbF2bUA4Qz417vf0HVpGMk=; b=ik3rDynrwKVK6u/Fft2DgXjVFnGxV7YmFoaABMXgdcdGdEaiiWugg+zJMVLMcGVL95 M+sHAx2pG6mioGQTkFsFQiNEW9JWxOT4kHvf//vFw67aOT28ZTNyyr32hE6VsnXeFDzh SPTBwGcMAog5f3K19U/eqSlaDlmY9fSbYs3WNHlu5s+WZIaQ7rJ15gpVudN13IYNYqK0 4FThcEfEpQefSRkObXjU7e/sWhqBag31+sLBXYQo3T90Ab8I0K3luRWyjd+kToRibkUD pw1iYmi4Ltabjjumrqt8Kco6V4NC9l/8qG2tZ7F44Yx1PX62TFCWLD3xupaoHc1GBM+T AVgA== X-Gm-Message-State: AOJu0Yw++Klk7hrlJzVVFIfQVEh7tRxubXiSP9GnlK3SoYo2dw2ZfY5H ViDMhUsH/0fb3nMcl1djp+pV1ffcgkgN2Yxcmik8t5j7ZbF6pAfOizOaYeVEhgM6er5MXMj/GjM 3/7w= X-Gm-Gg: ASbGncs5V1QJ2fLkblmC9DP6l4ETMq9jidpQUx8MdT605OGFWJYfYx+J48d57qv9sxS HmuOAvwUEbfzNVTtDHxPz2L9CepuhGvHhK3zgbMO1SDeCrkuQNvBrUUOKFqQYsELIeisVWUtaDp +vlgl4cgkK6T4gVBxT5WPJuUK6FNC1ieb7hLr9mxXeHG4MzQDZSWxatxiTG+TNQhAsrppHdoFNP 9/eFOQ/N5jKII+mrvrc/kwKuWIkGYzuUaWvdFIXCHleiwOzayx1e/375a2OSMiJQpKvc+/TC32c RNUn1tDAjMJsZTZ2eXz8YmO6GQ== X-Google-Smtp-Source: AGHT+IGWLkVKui5sLYe/J00bvAtphogkgFM5633HXFC41GQUdlKN3TskCgbE9ZFo2tYak4CR0J8Y2w== X-Received: by 2002:aa7:888d:0:b0:725:f1ca:fd75 with SMTP id d2e1a72fcca58-72abdd3c299mr26876054b3a.2.1735070955280; Tue, 24 Dec 2024 12:09:15 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 55/72] softfloat: Add float{16,32,64}_muladd_scalbn Date: Tue, 24 Dec 2024 12:05:04 -0800 Message-ID: <20241224200521.310066-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We currently have a flag, float_muladd_halve_result, to scale the result by 2**-1. Extend this to handle arbitrary scaling. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/fpu/softfloat.h | 6 ++++ fpu/softfloat.c | 58 ++++++++++++++++++++++----------------- fpu/softfloat-parts.c.inc | 7 +++-- 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index eb64075b9c..c34ce0477d 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -238,6 +238,8 @@ float16 float16_add(float16, float16, float_status *status); float16 float16_sub(float16, float16, float_status *status); float16 float16_mul(float16, float16, float_status *status); float16 float16_muladd(float16, float16, float16, int, float_status *status); +float16 float16_muladd_scalbn(float16, float16, float16, + int, int, float_status *status); float16 float16_div(float16, float16, float_status *status); float16 float16_scalbn(float16, int, float_status *status); float16 float16_min(float16, float16, float_status *status); @@ -597,6 +599,8 @@ float32 float32_mul(float32, float32, float_status *status); float32 float32_div(float32, float32, float_status *status); float32 float32_rem(float32, float32, float_status *status); float32 float32_muladd(float32, float32, float32, int, float_status *status); +float32 float32_muladd_scalbn(float32, float32, float32, + int, int, float_status *status); float32 float32_sqrt(float32, float_status *status); float32 float32_exp2(float32, float_status *status); float32 float32_log2(float32, float_status *status); @@ -792,6 +796,8 @@ float64 float64_mul(float64, float64, float_status *status); float64 float64_div(float64, float64, float_status *status); float64 float64_rem(float64, float64, float_status *status); float64 float64_muladd(float64, float64, float64, int, float_status *status); +float64 float64_muladd_scalbn(float64, float64, float64, + int, int, float_status *status); float64 float64_sqrt(float64, float_status *status); float64 float64_log2(float64, float_status *status); FloatRelation float64_compare(float64, float64, float_status *status); diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 8de8d5f342..b5936cc0f8 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -789,15 +789,15 @@ static FloatParts128 *parts128_mul(FloatParts128 *a, FloatParts128 *b, #define parts_mul(A, B, S) \ PARTS_GENERIC_64_128(mul, A)(A, B, S) -static FloatParts64 *parts64_muladd(FloatParts64 *a, FloatParts64 *b, - FloatParts64 *c, int flags, - float_status *s); -static FloatParts128 *parts128_muladd(FloatParts128 *a, FloatParts128 *b, - FloatParts128 *c, int flags, - float_status *s); +static FloatParts64 *parts64_muladd_scalbn(FloatParts64 *a, FloatParts64 *b, + FloatParts64 *c, int scale, + int flags, float_status *s); +static FloatParts128 *parts128_muladd_scalbn(FloatParts128 *a, FloatParts128 *b, + FloatParts128 *c, int scale, + int flags, float_status *s); -#define parts_muladd(A, B, C, Z, S) \ - PARTS_GENERIC_64_128(muladd, A)(A, B, C, Z, S) +#define parts_muladd_scalbn(A, B, C, Z, Y, S) \ + PARTS_GENERIC_64_128(muladd_scalbn, A)(A, B, C, Z, Y, S) static FloatParts64 *parts64_div(FloatParts64 *a, FloatParts64 *b, float_status *s); @@ -2212,43 +2212,50 @@ floatx80_mul(floatx80 a, floatx80 b, float_status *status) * Fused multiply-add */ -float16 QEMU_FLATTEN float16_muladd(float16 a, float16 b, float16 c, - int flags, float_status *status) +float16 QEMU_FLATTEN +float16_muladd_scalbn(float16 a, float16 b, float16 c, + int scale, int flags, float_status *status) { FloatParts64 pa, pb, pc, *pr; float16_unpack_canonical(&pa, a, status); float16_unpack_canonical(&pb, b, status); float16_unpack_canonical(&pc, c, status); - pr = parts_muladd(&pa, &pb, &pc, flags, status); + pr = parts_muladd_scalbn(&pa, &pb, &pc, scale, flags, status); return float16_round_pack_canonical(pr, status); } -static float32 QEMU_SOFTFLOAT_ATTR -soft_f32_muladd(float32 a, float32 b, float32 c, int flags, - float_status *status) +float16 float16_muladd(float16 a, float16 b, float16 c, + int flags, float_status *status) +{ + return float16_muladd_scalbn(a, b, c, 0, flags, status); +} + +float32 QEMU_SOFTFLOAT_ATTR +float32_muladd_scalbn(float32 a, float32 b, float32 c, + int scale, int flags, float_status *status) { FloatParts64 pa, pb, pc, *pr; float32_unpack_canonical(&pa, a, status); float32_unpack_canonical(&pb, b, status); float32_unpack_canonical(&pc, c, status); - pr = parts_muladd(&pa, &pb, &pc, flags, status); + pr = parts_muladd_scalbn(&pa, &pb, &pc, scale, flags, status); return float32_round_pack_canonical(pr, status); } -static float64 QEMU_SOFTFLOAT_ATTR -soft_f64_muladd(float64 a, float64 b, float64 c, int flags, - float_status *status) +float64 QEMU_SOFTFLOAT_ATTR +float64_muladd_scalbn(float64 a, float64 b, float64 c, + int scale, int flags, float_status *status) { FloatParts64 pa, pb, pc, *pr; float64_unpack_canonical(&pa, a, status); float64_unpack_canonical(&pb, b, status); float64_unpack_canonical(&pc, c, status); - pr = parts_muladd(&pa, &pb, &pc, flags, status); + pr = parts_muladd_scalbn(&pa, &pb, &pc, scale, flags, status); return float64_round_pack_canonical(pr, status); } @@ -2323,7 +2330,7 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s) return ur.s; soft: - return soft_f32_muladd(ua.s, ub.s, uc.s, flags, s); + return float32_muladd_scalbn(ua.s, ub.s, uc.s, 0, flags, s); } float64 QEMU_FLATTEN @@ -2394,7 +2401,7 @@ float64_muladd(float64 xa, float64 xb, float64 xc, int flags, float_status *s) return ur.s; soft: - return soft_f64_muladd(ua.s, ub.s, uc.s, flags, s); + return float64_muladd_scalbn(ua.s, ub.s, uc.s, 0, flags, s); } float64 float64r32_muladd(float64 a, float64 b, float64 c, @@ -2405,7 +2412,7 @@ float64 float64r32_muladd(float64 a, float64 b, float64 c, float64_unpack_canonical(&pa, a, status); float64_unpack_canonical(&pb, b, status); float64_unpack_canonical(&pc, c, status); - pr = parts_muladd(&pa, &pb, &pc, flags, status); + pr = parts_muladd_scalbn(&pa, &pb, &pc, 0, flags, status); return float64r32_round_pack_canonical(pr, status); } @@ -2418,7 +2425,7 @@ bfloat16 QEMU_FLATTEN bfloat16_muladd(bfloat16 a, bfloat16 b, bfloat16 c, bfloat16_unpack_canonical(&pa, a, status); bfloat16_unpack_canonical(&pb, b, status); bfloat16_unpack_canonical(&pc, c, status); - pr = parts_muladd(&pa, &pb, &pc, flags, status); + pr = parts_muladd_scalbn(&pa, &pb, &pc, 0, flags, status); return bfloat16_round_pack_canonical(pr, status); } @@ -2431,7 +2438,7 @@ float128 QEMU_FLATTEN float128_muladd(float128 a, float128 b, float128 c, float128_unpack_canonical(&pa, a, status); float128_unpack_canonical(&pb, b, status); float128_unpack_canonical(&pc, c, status); - pr = parts_muladd(&pa, &pb, &pc, flags, status); + pr = parts_muladd_scalbn(&pa, &pb, &pc, 0, flags, status); return float128_round_pack_canonical(pr, status); } @@ -5249,8 +5256,9 @@ float32 float32_exp2(float32 a, float_status *status) float64_unpack_canonical(&rp, float64_one, status); for (i = 0 ; i < 15 ; i++) { + float64_unpack_canonical(&tp, float32_exp2_coefficients[i], status); - rp = *parts_muladd(&tp, &xnp, &rp, 0, status); + rp = *parts_muladd_scalbn(&tp, &xnp, &rp, 0, 0, status); xnp = *parts_mul(&xnp, &xp, status); } diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index ba8de7be76..4a62d6ca24 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -562,8 +562,9 @@ static FloatPartsN *partsN(mul)(FloatPartsN *a, FloatPartsN *b, * Requires A and C extracted into a double-sized structure to provide the * extra space for the widening multiply. */ -static FloatPartsN *partsN(muladd)(FloatPartsN *a, FloatPartsN *b, - FloatPartsN *c, int flags, float_status *s) +static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a, FloatPartsN *b, + FloatPartsN *c, int scale, + int flags, float_status *s) { int ab_mask, abc_mask; FloatPartsW p_widen, c_widen; @@ -652,9 +653,11 @@ static FloatPartsN *partsN(muladd)(FloatPartsN *a, FloatPartsN *b, a->exp = p_widen.exp; return_normal: + /* TODO: Replace all use of float_muladd_halve_result with scale. */ if (flags & float_muladd_halve_result) { a->exp -= 1; } + a->exp += scale; finish_sign: if (flags & float_muladd_negate_result) { a->sign ^= 1; From patchwork Tue Dec 24 20:05:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90CA2E7718D for ; Tue, 24 Dec 2024 20:10:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDy-0001Wv-On; Tue, 24 Dec 2024 15:09:50 -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 1tQBDT-0006dQ-QV for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:20 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDS-0002xz-4W for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:19 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2165cb60719so57760375ad.0 for ; Tue, 24 Dec 2024 12:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070956; x=1735675756; 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=MKoswZ0+HzjatCwvvzude3nDWSM8RUV02VuNA19m0ac=; b=kp847CNw7g5ZE2ZUZgWnGD8MT8kNil/Lh3RycQJn1/Lrn4UI9EuL81BR6k6j9TamFa 4A6OaE3xsd+rORv6FOriyyGWsBP+yQiYd/N9+ooy0r8aQt3lUDBiTajjbWJnRCCb33oz fasUEoCHmefLmMIfSqvudN3fLLwf50nT/BqOQduBe0PDlg7eVGgjmkr6xvPOVCv0v3bT MiBxYaX5tSQYXYhakAHI6fAci769Q6RZ9LoyV+9w0JgMdSIDrQXzpGIeV11eFE8gSNAO aWkjzg719+GMdQQW7tvhaXGp2vo6K7A8toHhAHjDl933T4YhJtTlT1e3yi6BaYB6f3uR EhYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070956; x=1735675756; 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=MKoswZ0+HzjatCwvvzude3nDWSM8RUV02VuNA19m0ac=; b=QPi1nKl1VvUvxXj7SSusa6T+xxXYu4rrshdjJTEanjQpz2j1gT10slk1XSYZOwXJli ErXbPdR/rKLdpGC7+wbDgXJfucyTA91QiNzkF8Kbh7+mk7r41Z2uQbvA9tOfKF+U3Cbv CH9Ym7LZNPN6WIWAMDiUo7skK2zbzaVcisoyo52Xz3KqraE4rA4wNAtET1oUQS9plc98 QDQjybB6HVH3o1a5cy2z1ZvoKQZueaSqt6DpCeEMA14E5Lupk1nMvBPIFJwGFFm05GJb dEptHo5sveDTyulmsoJY8AdVfCwfaWgVs+uZgLPM9y7LzqhLNl3KoEeDjPYSyDb81bPX DpZQ== X-Gm-Message-State: AOJu0YzqhaBngt8+bXeb9zhzOl39LQrfjdGow3YFVrBbPNIw3KVzhTja ccTKQbSZSKQV9VIi4B54AGw4L61E+fCYFrGNk4uvOAnc4d4U/8oPqIG6R3yG63TJfOCdNAyf8DG FKns= X-Gm-Gg: ASbGnctKio1B2n2FPkIsjV+0ZRZDT3crY8wUaQCCj9PRo7ZRpOlFTX7Q/1Qhv6HAeAR 2MG1enM4VfB1uYAjJ5++BypyskwYFjYSrQaMKBn4synOfKQ+z8Q/qVnq2S0OtYN+ShANS7xPfa6 IUTb845tJrX7QRsvSsFGdbBUEjVNXm3xD9FQptvehlhwa/Dww0hnrAwII9N3btUwmQp8gGIcpAT dXCZ335Aa+0u5/OZZDx3dS/8hnhSVEnFg7SifU+YSNEKoke2lcz4LytxlqD4g8IOq3iZJZsQlpZ 5dqQPuIFr0lVpZIagE2EPstFfg== X-Google-Smtp-Source: AGHT+IEDblHEA9wUfsjiGcRIfKSQv0eqZVzS/4gR+pavyf6iJ2fh8GFr9GZTAUbzFqoBFVfNnuxbWg== X-Received: by 2002:a05:6a20:6a25:b0:1d9:6c9c:75ea with SMTP id adf61e73a8af0-1e5e0448930mr28347558637.5.1735070956205; Tue, 24 Dec 2024 12:09:16 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 56/72] target/arm: Use float*_muladd_scalbn Date: Tue, 24 Dec 2024 12:05:05 -0800 Message-ID: <20241224200521.310066-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the scalbn interface instead of float_muladd_halve_result. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/tcg/helper-a64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 0e130501fd..3b226daee7 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -262,7 +262,7 @@ uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, float_status *fpst) (float16_is_infinity(b) && float16_is_zero(a))) { return float16_one_point_five; } - return float16_muladd(a, b, float16_three, float_muladd_halve_result, fpst); + return float16_muladd_scalbn(a, b, float16_three, -1, 0, fpst); } float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, float_status *fpst) @@ -275,7 +275,7 @@ float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, float_status *fpst) (float32_is_infinity(b) && float32_is_zero(a))) { return float32_one_point_five; } - return float32_muladd(a, b, float32_three, float_muladd_halve_result, fpst); + return float32_muladd_scalbn(a, b, float32_three, -1, 0, fpst); } float64 HELPER(rsqrtsf_f64)(float64 a, float64 b, float_status *fpst) @@ -288,7 +288,7 @@ float64 HELPER(rsqrtsf_f64)(float64 a, float64 b, float_status *fpst) (float64_is_infinity(b) && float64_is_zero(a))) { return float64_one_point_five; } - return float64_muladd(a, b, float64_three, float_muladd_halve_result, fpst); + return float64_muladd_scalbn(a, b, float64_three, -1, 0, fpst); } /* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */ From patchwork Tue Dec 24 20:05:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D7F1E7718D for ; Tue, 24 Dec 2024 20:18:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDd-0007N9-Ay; Tue, 24 Dec 2024 15:09:29 -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 1tQBDU-0006og-OW for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:21 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDS-0002y6-Kg for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:20 -0500 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2efb17478adso5478455a91.1 for ; Tue, 24 Dec 2024 12:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070957; x=1735675757; 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=1WWVUuFJ12NWX3hZBTm/nR+nuzYhMWj/gdswxVh+HzA=; b=nRW6mibawrPYbgl5GP5Q4Bd0hil2z3UINtVaPUbH1lMVTimLBXKivYIvbPE/xtvfkz AD4QJQg38I2Yt1EWQnNrQI6pNrByW4yuKGcwzRKmld0QubLTjUyMWn7PwmwRIRFUZ2JE 3Cbz+fjf3/1Ss5K4RpEyTOlf0UTICCzuhpXQR6np7HiVnymbaeEaz29vHRgO5MsjPDoV egFML7YtwVJA6DLilV/sjd7xHZvBchOkDvcuvVnoTnCWHiku1sZnGLOsK7WBOW5sHzzX 5bAFzKY+tiUThFyX3yzNpADfPrDwpNthz3s2xm1FeDTRFvgjUGyU8TcHEPTB4NbT8krb 1y8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070957; x=1735675757; 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=1WWVUuFJ12NWX3hZBTm/nR+nuzYhMWj/gdswxVh+HzA=; b=TYsKCtk6Qq9HW+Elu5pgAJRTP9jrF/aaDukuuFBWvk4Bs9wfKVKhMl2Aj25NckLCMo P68u9WtDAWRYb+p2kSkR7eZnw9aU1hQJ/sCTB7YqHsOtM1SpUMqzDFFH7atQ4M881XCK mIScbUpbpViwF8Fcmyrje/sOzN6qFN0RF5JA1McNCxz5kJ3xCeXEl6Oio4ztvjEQTGip dxfTBB33lDEy2g+8GWHOYOSklVo5yd7IhLloqhc+ke1duSpbrZNrwkrFcZibpbQ1rRAg xduw3IhHGR1dibRzvP1NeXsmtALxTzGKuyuk17p53kBAGmjOH94V8xVmqgtSJc8xjrRX 13PQ== X-Gm-Message-State: AOJu0Yyu1P/TtwhKbrmHkxZNPyidZHNMaE4m2bePmwhQuXPGG2hloZ60 nHFcciXwN4rFeHrHmAc3J4l64kZwFIY2Tv3BnRY5loWm8Jwtxa+AKXi9Yi+fN1n3h8rrHXj9CxM A+Ug= X-Gm-Gg: ASbGnct7UZD4np8dSBu0HZKXxOdTNtYvbvJH0kkuU2tedFy3j0Ot030Gk9VwNalf2s3 u/tDayR2KzRWRG0VsY9TiJ08SdK+dYQ2bkZP2YCWDEtNMSywIGuN5FV4ZzJHfpjaSVHhwJyWV9c LQcYYNr2edHzmjk8+DQh/YrKvknpC69wNzIPRqhJy3UTVvuM1L0K/ySsUxL0YJUB4ytzaTvpj08 rGc86kFE0h60b76+QH7+AzSktZKY3cJJ1tFQ8JNOnjV4d8HBtkItvzfsVkbw5Xtk9Jp4PEuBKu8 ci6JaQ6UxAG2EvWhcuWx5XfPzg== X-Google-Smtp-Source: AGHT+IGfx+7TMDPx5mydqtgWJjVpEb5zqmuUKVyvm6Gy5oCxPlE89VoTN3lEm/ZgVooGalHoO/PFgw== X-Received: by 2002:a05:6a00:1944:b0:71d:f4ef:6b3a with SMTP id d2e1a72fcca58-72abdeb6e80mr26145144b3a.21.1735070957102; Tue, 24 Dec 2024 12:09:17 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 57/72] target/sparc: Use float*_muladd_scalbn Date: Tue, 24 Dec 2024 12:05:06 -0800 Message-ID: <20241224200521.310066-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the scalbn interface instead of float_muladd_halve_result. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/sparc/helper.h | 4 +- target/sparc/fop_helper.c | 8 ++-- target/sparc/translate.c | 80 +++++++++++++++++++++++---------------- 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/target/sparc/helper.h b/target/sparc/helper.h index 1ae3f0c467..3a7f7dc129 100644 --- a/target/sparc/helper.h +++ b/target/sparc/helper.h @@ -59,7 +59,7 @@ DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fsubd, TCG_CALL_NO_WG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fmuld, TCG_CALL_NO_WG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fdivd, TCG_CALL_NO_WG, f64, env, f64, f64) -DEF_HELPER_FLAGS_5(fmaddd, TCG_CALL_NO_WG, f64, env, f64, f64, f64, i32) +DEF_HELPER_FLAGS_6(fmaddd, TCG_CALL_NO_WG, f64, env, f64, f64, f64, s32, i32) DEF_HELPER_FLAGS_3(fnaddd, TCG_CALL_NO_WG, f64, env, f64, f64) DEF_HELPER_FLAGS_3(fnmuld, TCG_CALL_NO_WG, f64, env, f64, f64) @@ -72,7 +72,7 @@ DEF_HELPER_FLAGS_3(fadds, TCG_CALL_NO_WG, f32, env, f32, f32) DEF_HELPER_FLAGS_3(fsubs, TCG_CALL_NO_WG, f32, env, f32, f32) DEF_HELPER_FLAGS_3(fmuls, TCG_CALL_NO_WG, f32, env, f32, f32) DEF_HELPER_FLAGS_3(fdivs, TCG_CALL_NO_WG, f32, env, f32, f32) -DEF_HELPER_FLAGS_5(fmadds, TCG_CALL_NO_WG, f32, env, f32, f32, f32, i32) +DEF_HELPER_FLAGS_6(fmadds, TCG_CALL_NO_WG, f32, env, f32, f32, f32, s32, i32) DEF_HELPER_FLAGS_3(fnadds, TCG_CALL_NO_WG, f32, env, f32, f32) DEF_HELPER_FLAGS_3(fnmuls, TCG_CALL_NO_WG, f32, env, f32, f32) diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c index 236d27b19c..c25097d07f 100644 --- a/target/sparc/fop_helper.c +++ b/target/sparc/fop_helper.c @@ -344,17 +344,17 @@ Int128 helper_fsqrtq(CPUSPARCState *env, Int128 src) } float32 helper_fmadds(CPUSPARCState *env, float32 s1, - float32 s2, float32 s3, uint32_t op) + float32 s2, float32 s3, int32_t sc, uint32_t op) { - float32 ret = float32_muladd(s1, s2, s3, op, &env->fp_status); + float32 ret = float32_muladd_scalbn(s1, s2, s3, sc, op, &env->fp_status); check_ieee_exceptions(env, GETPC()); return ret; } float64 helper_fmaddd(CPUSPARCState *env, float64 s1, - float64 s2, float64 s3, uint32_t op) + float64 s2, float64 s3, int32_t sc, uint32_t op) { - float64 ret = float64_muladd(s1, s2, s3, op, &env->fp_status); + float64 ret = float64_muladd_scalbn(s1, s2, s3, sc, op, &env->fp_status); check_ieee_exceptions(env, GETPC()); return ret; } diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 9be26c804e..465e20f4f3 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1359,93 +1359,109 @@ static void gen_op_fabsq(TCGv_i128 dst, TCGv_i128 src) static void gen_op_fmadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3) { - gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(0)); + TCGv_i32 z = tcg_constant_i32(0); + gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, z); } static void gen_op_fmaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3) { - gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(0)); + TCGv_i32 z = tcg_constant_i32(0); + gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, z); } static void gen_op_fmsubs(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3) { - int op = float_muladd_negate_c; - gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(op)); + TCGv_i32 z = tcg_constant_i32(0); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c); + gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, op); } static void gen_op_fmsubd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3) { - int op = float_muladd_negate_c; - gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(op)); + TCGv_i32 z = tcg_constant_i32(0); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c); + gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, op); } static void gen_op_fnmsubs(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3) { - int op = float_muladd_negate_c | float_muladd_negate_result; - gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(op)); + TCGv_i32 z = tcg_constant_i32(0); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c | + float_muladd_negate_result); + gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, op); } static void gen_op_fnmsubd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3) { - int op = float_muladd_negate_c | float_muladd_negate_result; - gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(op)); + TCGv_i32 z = tcg_constant_i32(0); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c | + float_muladd_negate_result); + gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, op); } static void gen_op_fnmadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2, TCGv_i32 s3) { - int op = float_muladd_negate_result; - gen_helper_fmadds(d, tcg_env, s1, s2, s3, tcg_constant_i32(op)); + TCGv_i32 z = tcg_constant_i32(0); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result); + gen_helper_fmadds(d, tcg_env, s1, s2, s3, z, op); } static void gen_op_fnmaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2, TCGv_i64 s3) { - int op = float_muladd_negate_result; - gen_helper_fmaddd(d, tcg_env, s1, s2, s3, tcg_constant_i32(op)); + TCGv_i32 z = tcg_constant_i32(0); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result); + gen_helper_fmaddd(d, tcg_env, s1, s2, s3, z, op); } /* Use muladd to compute (1 * src1) + src2 / 2 with one rounding. */ static void gen_op_fhadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2) { - TCGv_i32 one = tcg_constant_i32(float32_one); - int op = float_muladd_halve_result; - gen_helper_fmadds(d, tcg_env, one, s1, s2, tcg_constant_i32(op)); + TCGv_i32 fone = tcg_constant_i32(float32_one); + TCGv_i32 mone = tcg_constant_i32(-1); + TCGv_i32 op = tcg_constant_i32(0); + gen_helper_fmadds(d, tcg_env, fone, s1, s2, mone, op); } static void gen_op_fhaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2) { - TCGv_i64 one = tcg_constant_i64(float64_one); - int op = float_muladd_halve_result; - gen_helper_fmaddd(d, tcg_env, one, s1, s2, tcg_constant_i32(op)); + TCGv_i64 fone = tcg_constant_i64(float64_one); + TCGv_i32 mone = tcg_constant_i32(-1); + TCGv_i32 op = tcg_constant_i32(0); + gen_helper_fmaddd(d, tcg_env, fone, s1, s2, mone, op); } /* Use muladd to compute (1 * src1) - src2 / 2 with one rounding. */ static void gen_op_fhsubs(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2) { - TCGv_i32 one = tcg_constant_i32(float32_one); - int op = float_muladd_negate_c | float_muladd_halve_result; - gen_helper_fmadds(d, tcg_env, one, s1, s2, tcg_constant_i32(op)); + TCGv_i32 fone = tcg_constant_i32(float32_one); + TCGv_i32 mone = tcg_constant_i32(-1); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c); + gen_helper_fmadds(d, tcg_env, fone, s1, s2, mone, op); } static void gen_op_fhsubd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2) { - TCGv_i64 one = tcg_constant_i64(float64_one); - int op = float_muladd_negate_c | float_muladd_halve_result; - gen_helper_fmaddd(d, tcg_env, one, s1, s2, tcg_constant_i32(op)); + TCGv_i64 fone = tcg_constant_i64(float64_one); + TCGv_i32 mone = tcg_constant_i32(-1); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_c); + gen_helper_fmaddd(d, tcg_env, fone, s1, s2, mone, op); } /* Use muladd to compute -((1 * src1) + src2 / 2) with one rounding. */ static void gen_op_fnhadds(TCGv_i32 d, TCGv_i32 s1, TCGv_i32 s2) { - TCGv_i32 one = tcg_constant_i32(float32_one); - int op = float_muladd_negate_result | float_muladd_halve_result; - gen_helper_fmadds(d, tcg_env, one, s1, s2, tcg_constant_i32(op)); + TCGv_i32 fone = tcg_constant_i32(float32_one); + TCGv_i32 mone = tcg_constant_i32(-1); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result); + gen_helper_fmadds(d, tcg_env, fone, s1, s2, mone, op); } static void gen_op_fnhaddd(TCGv_i64 d, TCGv_i64 s1, TCGv_i64 s2) { - TCGv_i64 one = tcg_constant_i64(float64_one); - int op = float_muladd_negate_result | float_muladd_halve_result; - gen_helper_fmaddd(d, tcg_env, one, s1, s2, tcg_constant_i32(op)); + TCGv_i64 fone = tcg_constant_i64(float64_one); + TCGv_i32 mone = tcg_constant_i32(-1); + TCGv_i32 op = tcg_constant_i32(float_muladd_negate_result); + gen_helper_fmaddd(d, tcg_env, fone, s1, s2, mone, op); } static void gen_op_fpexception_im(DisasContext *dc, int ftt) From patchwork Tue Dec 24 20:05:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24986E77188 for ; Tue, 24 Dec 2024 20:13:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDm-0008QL-Dh; Tue, 24 Dec 2024 15:09:38 -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 1tQBDV-0006uA-Gb for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:21 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDT-0002yF-I8 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:21 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2161eb94cceso39855885ad.2 for ; Tue, 24 Dec 2024 12:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070958; x=1735675758; 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=DNZINX2but2Pfb8ZOCVoSmAmmZqPR58yrma436JYpx8=; b=KwSRT+KcH7MgyHOtDyq5XmPTzoqcNKuvSAi7VuB/OwOW+Fmk94CwgyOddiCGKFDXbh JUsQaPT3aL64sKAvplEBtMeCc94UriLAxNDD74dYmLy7hRtxNFh/triM12/7l42Gg9Y9 2dU9jb8s8Ce84DmmwvbxD/GFDRJpletHZWukKPIWvGtyJBTY/OfK+pwiqyeu4Qibzpsj p+m/yOPppOrQVWLigq/V70qTZOJy/FCs9dRGe19JvDM2w0owkfgCBYLTMJYC01pAT/yg gC9qpVIm8d4cMYlLTu3pl2y0J53I+2ySj1kAH8apr3fOL61cFlxVCNgoT0nqF6M8UteQ AgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070958; x=1735675758; 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=DNZINX2but2Pfb8ZOCVoSmAmmZqPR58yrma436JYpx8=; b=LFODBmFeAqj178tIPQ6C3VxJbL+gJgetL111SzoB2PEXlAlpy00TGV9lDpe3rkQjlG A1tGpPnYR4zRtkIQNO/ocZZ4lmwVeRe3jebk5GmXBWjRzbjhDb/K22SIn1Xx8+ekVezf 9OaZ2rGsOpeeE37/JF+AHYff2gJPBFU5q3D4U9g4CTsHZBjNLe7/C3M33MrlZ2tgOkgO SwUjU8OxZjgLaaclp+t6riXYzTy1Bz2OB8x3X8sexatqE7X1Xnd4xYoZzYT5k+9DcN21 co6dvXL87fDS+0ZPm5hDtAvzoJGT4kSChrBhlDJXd164OyF0dvPtXgWMI+5HKnc/uvDf eIEQ== X-Gm-Message-State: AOJu0YwerBEHdhFyuTeDk5hMvaiTWiw4Mbe6hmRjgJvRNrfGlbGhWQCY 217DNy4gZvZA7FEKbW5tA0/WhRZfuBhNnisiPILoNw6wHFENmAKuyD8NRmDA39fd3c3+NDGWbG8 9nU8= X-Gm-Gg: ASbGncsdSPNX4GPPJLyBBPWhQZZ4tf/gxMbzKwfzF0Uzkft15vBw1NKM8CQRERruQi8 C6qAvy6b/xK/PRq9O2X3rx8XoXSa/bYfYG+CtbeMiWfRPITVbjGGyBtJX8EZqCZFvskAgIVDAvv KpAaTh606MxFmleMrjsGxNKmV2gZfSGevJ3SdzBcz6c4Gnv5QMvZb5P+tu1Zx6PQ8W5aqwCKVq/ Qfrtp4ChnSt7WAQzWZSPM3DBhXqQh1OU4KjcL0/1n6x3+oSHQ/t7MZ20/FqNBGEjjexlAzjmR/+ Tp5QWbGQHbXz2qusTN+YW8q3Sw== X-Google-Smtp-Source: AGHT+IErbrhKU+oKKAvSzwkU3ymecNmd8zL3Z0AHMYDqwlEbcFobWis3YorU2v7AoW1i6Od1alwFzw== X-Received: by 2002:a05:6a00:2449:b0:728:e906:e45a with SMTP id d2e1a72fcca58-72abdecdbfdmr28215787b3a.24.1735070957893; Tue, 24 Dec 2024 12:09:17 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 58/72] softfloat: Remove float_muladd_halve_result Date: Tue, 24 Dec 2024 12:05:07 -0800 Message-ID: <20241224200521.310066-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All uses have been convered to float*_muladd_scalbn. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/fpu/softfloat.h | 3 --- fpu/softfloat.c | 6 ------ fpu/softfloat-parts.c.inc | 4 ---- 3 files changed, 13 deletions(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index c34ce0477d..aa69aecfb0 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -120,14 +120,11 @@ bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status); | Using these differs from negating an input or output before calling | the muladd function in that this means that a NaN doesn't have its | sign bit inverted before it is propagated. -| We also support halving the result before rounding, as a special -| case to support the ARM fused-sqrt-step instruction FRSQRTS. *----------------------------------------------------------------------------*/ enum { float_muladd_negate_c = 1, float_muladd_negate_product = 2, float_muladd_negate_result = 4, - float_muladd_halve_result = 8, }; /*---------------------------------------------------------------------------- diff --git a/fpu/softfloat.c b/fpu/softfloat.c index b5936cc0f8..6967fb5c9f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2274,9 +2274,6 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s) if (unlikely(!can_use_fpu(s))) { goto soft; } - if (unlikely(flags & float_muladd_halve_result)) { - goto soft; - } float32_input_flush3(&ua.s, &ub.s, &uc.s, s); if (unlikely(!f32_is_zon3(ua, ub, uc))) { @@ -2345,9 +2342,6 @@ float64_muladd(float64 xa, float64 xb, float64 xc, int flags, float_status *s) if (unlikely(!can_use_fpu(s))) { goto soft; } - if (unlikely(flags & float_muladd_halve_result)) { - goto soft; - } float64_input_flush3(&ua.s, &ub.s, &uc.s, s); if (unlikely(!f64_is_zon3(ua, ub, uc))) { diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 4a62d6ca24..a724f317c5 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -653,10 +653,6 @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a, FloatPartsN *b, a->exp = p_widen.exp; return_normal: - /* TODO: Replace all use of float_muladd_halve_result with scale. */ - if (flags & float_muladd_halve_result) { - a->exp -= 1; - } a->exp += scale; finish_sign: if (flags & float_muladd_negate_result) { From patchwork Tue Dec 24 20:05:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920496 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B025BE77188 for ; Tue, 24 Dec 2024 20:10:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDg-0007VC-HN; Tue, 24 Dec 2024 15:09:33 -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 1tQBDV-0006wf-P7 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:21 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDU-0002yS-0R for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:21 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2166022c5caso50557955ad.2 for ; Tue, 24 Dec 2024 12:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070959; x=1735675759; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VUIKMuGpZcO333SHRrlgYIo9hY7EVMRSpYe/wTFZLaI=; b=xPuf381Psyw8zye033aHwe0G8pGlidd+1CYnlUfFeKJ5v9dCbcndCR56zGjhR2/Sn5 TZMO5P+0K6Dos+vvCq2NW2KeBMNB0MBUS+lcZ414T7vV9chvxicAVpSNbEAp3v+uJfzX Hfo+sJAGTP/ETrH580EepUdXH12dhqXC2//BfOGeVDayCYGd9m4xnrLCjXeISZfnqSvk cUQFUMTBCC35yklc0I8Q6gDjk4hxic+vTts4OqiUAUpxVl2Vujq7IgSZTl+CLvvOHkY9 ydEGDtmTmTBIN4uMi1g2k5YTMp8o+/pGgdtyNzWgBXdVo/jVRzHwZupUWf3FNZpoUywN XsQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070959; x=1735675759; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VUIKMuGpZcO333SHRrlgYIo9hY7EVMRSpYe/wTFZLaI=; b=d7ME0vTje7w9X24q0T9Pjlub21Z0Z2Xlsg4NY3IpLIDYLFVOgeYeM6IrHBgY3ZyrAU cMFgzMSjMS7pDbbsVp9N96gpfP8G2X4xLL6OvVK2aiK7gU2i0oYnGQiDLHMLBkqIsxKs PUur/npfan17Iy46SYfdV40DsXLR/hWf6IdKimOtFUrKp8jCR2nDENGdejcRJdLHlIDy fxwhhVEWPAL1NiUdYmZUjk6K2tUdn7ioXhiZBjDTJivTUIq1MK00IHCkIRin2rhqZFDF oKmuE414Plu7pK8s0jLLntV42fImewczcWKCSNfVplwWPkLYfsKetvGSKOSqtH0j0tLf ryCA== X-Gm-Message-State: AOJu0YxVMWHk98NH8pCZi6kMZQWHSU4PIf1dEZ35iL2B9jBEPR/CVukT uBlfB2J5UnPaK9jS0QeI5YveQe3hTSMiLLfeCEK2cuaVoz0UI67IUNqTzSKrMIQK94Wp4dyqo7P Rctk= X-Gm-Gg: ASbGncsjSRaUmmf7W4NvIAxXBThw2xxtYQ51trvFq+r7Rg+pNQ9dyKuMM9tM9spSg2D IXT1W7UAARoXqveSRUxCOdMGAHDenB591ZwY4OPjIU1VsYPy54Sttian1DOzcoZHFBXjQNmcr+a LbYyzeQ0D6/mz+1PqqaGsIkPzi9mFokkQt50/dX4/l9XYif/5U5VK56UgunNdBa58y1txMB4c+G iuLqE810Aoq4OHoTaSYdVd9ayoXhs+GboKWRL1olZyrQdcTKaNJxz44X7cB25lGiN78kn9NjHnM cf8Y6P2k2/kv9bAcnkCJiCHT/g== X-Google-Smtp-Source: AGHT+IHosgTQiG47smae7drmSIgIpOP8jmI73YBiq/FH0psrJHepFqx9R7C5KTaQsZNz/9yarPl4FQ== X-Received: by 2002:a05:6a00:918a:b0:725:322a:922c with SMTP id d2e1a72fcca58-72abdd20f53mr24150743b3a.3.1735070958732; Tue, 24 Dec 2024 12:09:18 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 59/72] softfloat: Add float_round_nearest_even_max Date: Tue, 24 Dec 2024 12:05:08 -0800 Message-ID: <20241224200521.310066-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This rounding mode is used by Hexagon. Signed-off-by: Richard Henderson --- include/fpu/softfloat-types.h | 2 ++ fpu/softfloat-parts.c.inc | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 79ca44dcc3..9d37cdfaa8 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -140,6 +140,8 @@ typedef enum __attribute__((__packed__)) { float_round_to_odd = 5, /* Not an IEEE rounding mode: round to closest odd, overflow to inf */ float_round_to_odd_inf = 6, + /* Not an IEEE rounding mode: round to nearest even, overflow to max */ + float_round_nearest_even_max = 7, } FloatRoundMode; /* diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index a724f317c5..37d046cfe9 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -241,6 +241,9 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s, int exp, flags = 0; switch (s->float_rounding_mode) { + case float_round_nearest_even_max: + overflow_norm = true; + /* fall through */ case float_round_nearest_even: if (N > 64 && frac_lsb == 0) { inc = ((p->frac_hi & 1) || (p->frac_lo & round_mask) != frac_lsbm1 From patchwork Tue Dec 24 20:05: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: 13920516 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69D50E7718D for ; Tue, 24 Dec 2024 20:16:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDo-0000Mn-Ok; Tue, 24 Dec 2024 15:09:40 -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 1tQBDW-000732-Jv for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:23 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDU-0002yf-Tp for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:22 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-216634dd574so40016175ad.2 for ; Tue, 24 Dec 2024 12:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070960; x=1735675760; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qMWHCU8E787jJTfENdcTGiVxd4zzSlvdX30p3jl01M4=; b=GffYiqBNLAzxx3KVZWPF2Dj7oSAR+LbBeZkxm7SDygpT4kYdh37DH7aO8rDMykmEyQ iVAyJ1NAiRsCGpIPQxMugFyt65Daprwv2dJz3oSgnM2uG3JlK1rEiZxtdmUfg6jVseet o9rWkaUeY6/8vmFqY4yJtvzgYMYpB8UKom/4rL1nNv8WHrGWqHyHpwQb1KCDSfMSzFGp q8zV11EihlFqEGxLFMNsHmucUdvIS2H+gfkLVEBz8cJVBEZybMBBYid3e/EncpDhqydS 9KaIB8V4f/I8JIRygOJDHvAaE/xCOI8+hynTlWmf1NftX1h+oQJMeyUlJa7eIXh+DizD cCMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070960; x=1735675760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qMWHCU8E787jJTfENdcTGiVxd4zzSlvdX30p3jl01M4=; b=WCtj3/uewzLnK9FHss2dCGWIS6R0SD6GpV7CVR7DgWz12eFW5ZcTZESsamcbWz48WY Sbv7TDMp+ru+noiKaHozqG3WUCcSFDozGDAgWJfijkWLYFB5hyxBY2u8+ogjKBYtvVIl BezkvyoKZKdDxdf9XpYAeH5Zh18EJUAzqeP9TIItXInz01Ld/4GZDSNXpbYxA3cu3SQA ZrkP/garK5s5q59S5RHGqIhGx6y+mzvCmFmmtwTZSv+yi/c2ILLsRbBf5upo31tWFXwn bQ60nHOFPAcFmFJ7Qre039I3UmIr6zWIIkG0PPyLEElZuFwZN6C6bkXR6+vpJoOpJd2K tzdA== X-Gm-Message-State: AOJu0Yw9bn0h6GMn+sitm2SMKk8X0ywEJ05PfUv1OeXK9DrR+roafQXt n+QCK+hsENcZMxlyYZ11jdTDMHnb0PQlqp/8w+KtOZIHnwa35hlTNv5aVZSN3KnaYEpCgR4SRkw yNwA= X-Gm-Gg: ASbGncvAOqoNs49svkejSzHMNH0epRhNbK/2siSNljhNMy2JEHah7cZmsHaQ+eb5vUA ZrfShC9nNeDXxLnO6WDEcCXAQqxY/wjUkTblHE2OC78HLtoxbMIXt91R1bww5jHuqj1hObeaPwx wQ+zErjKPgULD/jw6TYHHcdtMPcZgiWWR6g5xIn8C4FHRTtuj77i08eOOCIqQOd0CGC5R56ACN1 4gUudfZLoguaLzcTaLfxeb/2OjJQjyc7M98VlyGCj3Fpk3VzIL/0gVElC6oqfV5yuKrEgcGBy5s s9yqqhd/wGn+vsIMBygYeJFs0w== X-Google-Smtp-Source: AGHT+IFdtV4HZG6C5IKjSmTWi7b+ImB6uEVWHa9QsEgWvkjEBxTZvCGOAzp+zpRtgGJOQ9Slu6e7fQ== X-Received: by 2002:a05:6a21:6f87:b0:1db:c20f:2c4d with SMTP id adf61e73a8af0-1e5e044b1c1mr27570093637.2.1735070959723; Tue, 24 Dec 2024 12:09:19 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 60/72] softfloat: Add float_muladd_suppress_add_product_zero Date: Tue, 24 Dec 2024 12:05:09 -0800 Message-ID: <20241224200521.310066-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Certain Hexagon instructions suppress changes to the result when the product of fma() is a true zero. Signed-off-by: Richard Henderson --- include/fpu/softfloat.h | 5 +++++ fpu/softfloat.c | 3 +++ fpu/softfloat-parts.c.inc | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index aa69aecfb0..09a40b4310 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -120,11 +120,16 @@ bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status); | Using these differs from negating an input or output before calling | the muladd function in that this means that a NaN doesn't have its | sign bit inverted before it is propagated. +| +| With float_muladd_suppress_add_product_zero, if A or B is zero +| such that the product is a true zero, then return C without addition. +| This preserves the sign of C when C is +/- 0. Used for Hexagon. *----------------------------------------------------------------------------*/ enum { float_muladd_negate_c = 1, float_muladd_negate_product = 2, float_muladd_negate_result = 4, + float_muladd_suppress_add_product_zero = 8, }; /*---------------------------------------------------------------------------- diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6967fb5c9f..8d75d66817 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2274,6 +2274,9 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s) if (unlikely(!can_use_fpu(s))) { goto soft; } + if (unlikely(flags & float_muladd_suppress_add_product_zero)) { + goto soft; + } float32_input_flush3(&ua.s, &ub.s, &uc.s, s); if (unlikely(!f32_is_zon3(ua, ub, uc))) { diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 37d046cfe9..ebde42992f 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -615,7 +615,9 @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a, FloatPartsN *b, goto return_normal; } if (c->cls == float_class_zero) { - if (a->sign != c->sign) { + if (flags & float_muladd_suppress_add_product_zero) { + a->sign = c->sign; + } else if (a->sign != c->sign) { goto return_sub_zero; } goto return_zero; From patchwork Tue Dec 24 20:05:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EBB7E77188 for ; Tue, 24 Dec 2024 20:18:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDt-00019I-7M; Tue, 24 Dec 2024 15:09:45 -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 1tQBDY-00073P-Uk for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:25 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDV-0002yv-W5 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:23 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2163dc5155fso55567595ad.0 for ; Tue, 24 Dec 2024 12:09:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070961; x=1735675761; 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=dTGDXG/LHK+cbArsNVQoTZPhYd/l2OlGD8Apa8yjd5c=; b=imwiTqt55KHmMFeNaE75nII/ZaBDuPy4V2/0CiYKrGhPJvZP3fo5s52aC3fAaCl/nI j7p3BAT7W1iST011QE1d4DXMdkLgOgCfa5fRNJJs8Uo7FNQHDrWjVoYmwUPIJTRhQ4pJ vkFs+tKIaOXDq4a6QeGaZswt/h73Sw75jK7REzqhFlLiSYwIFYyvjmaGwD+zFOaLhfcn BMGJOtQuCTdDR+aeumsK8xT76gM26uRH+v6AL6Yte7vLEbzv/K+VFSr54EKyXkBz8GZz xOrjVALZWUueqs84l5SaIn58YwXecIj5bbG7SmLgErS+xC7+C8FQ1bTFB6UQIsXzXPff ftbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070961; x=1735675761; 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=dTGDXG/LHK+cbArsNVQoTZPhYd/l2OlGD8Apa8yjd5c=; b=NHVsSth9vzU778W/Kk2Y1v7EdVLkAMSzp9NllZXFVkjB2ez9hEshBiw8ReRIG0l9S1 OFH6TKfVav1ro4GWPMDDSC8AygH6s4VekW5xw+bC4kRKQqobRDs8GegMpY3CszChZ2mM DTjipaUYDTwL/LJ6UDBbJ5A2DFjEROUOZfrpJzX+I3EQTsZImw7dZ6fcjoxec0IsWgs5 RRANxG/fMjlDWYBpAnQ8C1EmuRhDOfvv9iWzksC8L1YSlA5vb8focMIwMMptdcLuG8b4 Y+jD7n+AMVjl9PPdiAGq1iCWaNpxJTJwMJXCZFkHhuctL10OuHCF78z4uXTXTM04+Q1R 84+A== X-Gm-Message-State: AOJu0YyrZFzuy11SuNdC9z3/h0z+4QiNvdhOt8ChQtlV2aQrtEzwgs5K oOZx6sXJbTFrHWpyE71scjm4x1qJjHK+kEMdP2wquc4wfM+X3XqWg1hXomJRusjyYo0QXeHMsP/ 1++U= X-Gm-Gg: ASbGncub3ERq56oZkJiLTCj90ck1uHcfI4x0CLi/nk6VunFUuQm2EGA2iEf9O4tbO1N cqx2Aw0/TOKVQJbSLgyBFOMEzKJiuI4fD7Xn796gqKUE1vnwypP1hCLthPQWq15VjHZWVCdjkCO dcIZrR4JApxvV7/9yDvJvf2w3YZqb30VtJDxh+7z+1mbgUn4OuYuRClgQf5v1anF3hCw98bCdRs GJPkFVtcMTFIw586eJBasXk2/g43wfLLcNhXvPcPfA4sMSsDus5wWvDoLWnd7Hd67mX9fWhEclC yQGCX2GWspSxLJdpW3XxAL4hCg== X-Google-Smtp-Source: AGHT+IFRCWpNSIzAmDr6P7A4FDXFnFAvgrsxGpgNR/bkTlhB+xuygYXOj2HYo4kFWq24oiREhUpjFw== X-Received: by 2002:a05:6a00:a95:b0:725:d956:aa6f with SMTP id d2e1a72fcca58-72abdd5eea8mr28794770b3a.5.1735070960766; Tue, 24 Dec 2024 12:09:20 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 61/72] target/hexagon: Use float32_mul in helper_sfmpy Date: Tue, 24 Dec 2024 12:05:10 -0800 Message-ID: <20241224200521.310066-62-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There are no special cases for this instruction. Remove internal_mpyf as unused. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.h | 1 - target/hexagon/fma_emu.c | 8 -------- target/hexagon/op_helper.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/target/hexagon/fma_emu.h b/target/hexagon/fma_emu.h index 91591d6050..ad5df5d038 100644 --- a/target/hexagon/fma_emu.h +++ b/target/hexagon/fma_emu.h @@ -32,7 +32,6 @@ int32_t float32_getexp(float32 f32); float32 infinite_float32(uint8_t sign); float32 internal_fmafx(float32 a, float32 b, float32 c, int scale, float_status *fp_status); -float32 internal_mpyf(float32 a, float32 b, float_status *fp_status); float64 internal_mpyhh(float64 a, float64 b, unsigned long long int accumulated, float_status *fp_status); diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index 05a56d8c10..35971b8b99 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -655,14 +655,6 @@ float32 internal_fmafx(float32 a, float32 b, float32 c, int scale, return accum_round_float32(result, fp_status); } -float32 internal_mpyf(float32 a, float32 b, float_status *fp_status) -{ - if (float32_is_zero(a) || float32_is_zero(b)) { - return float32_mul(a, b, fp_status); - } - return internal_fmafx(a, b, float32_zero, 0, fp_status); -} - float64 internal_mpyhh(float64 a, float64 b, unsigned long long int accumulated, float_status *fp_status) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 01d1a1b1a7..d257097091 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -1045,7 +1045,7 @@ float32 HELPER(sfmpy)(CPUHexagonState *env, float32 RsV, float32 RtV) { float32 RdV; arch_fpop_start(env); - RdV = internal_mpyf(RsV, RtV, &env->fp_status); + RdV = float32_mul(RsV, RtV, &env->fp_status); arch_fpop_end(env); return RdV; } From patchwork Tue Dec 24 20:05:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A2A7E77188 for ; Tue, 24 Dec 2024 20:13:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBE9-00038l-6B; Tue, 24 Dec 2024 15:10:01 -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 1tQBDZ-00078W-IN for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:26 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDX-0002zB-3E for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:25 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-216728b1836so49419825ad.0 for ; Tue, 24 Dec 2024 12:09:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070962; x=1735675762; 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=fu0SQWVVGdmrru8Sp2YT+Mtrtw7meBa6dVTFQbMXPPI=; b=DNbx3tw/Nbu9RQ4IQEWCHnDHBWIA+mYUAfTf0A76Qq+JgqSFFvkZ0I6FnKGdgPggQ0 Mq79bHqfWn27dgdkIAEvQNJ3SvTR+55aiE+OYJrPT1MPlOvPYJGO7qw87/RS98RlKJk4 YGZ7Bvt3NO0FS5tnSmbr0W2hebAPy2N/H+ZjZda2Wbl2V6Y9r44irHYTfcauZvBmPGYS s/Kr7w3r3KB3vS0Ol67CnMBle1UbJyZ7T8sn1gC0rmwtx5kSl85bS63FJLSkMIIOvBH/ sA1hLUaQglwz46QajY3PNiL6z0//NesoPo2tY1+czcC//cn8Al/47BnglCooJHlkus6c MUtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070962; x=1735675762; 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=fu0SQWVVGdmrru8Sp2YT+Mtrtw7meBa6dVTFQbMXPPI=; b=tpuOBLDAWTtyKKyfYi7+t8TdAQD0tkCTnTXnhsoQf7dU0OKtMRPWpa4CxMBb5jZeHh DkeRVN8NT6KduSQ7csfvJ+gaWhfog7AAhECWIbfKvLzCBrAEYUjQZrmh8ILjVS7e8odg JEmtHTkaJDKZFPBQsDk81iSOeSFlFCxF23+TkPdzpLs0zDMS6+RgvfD9O+ikX/xyigjf qLRN3aFbpecTI+Q54S9gaBCwkXmPi0Cd8C33XHUVw4UIlZbKzgpa701I77NUo9i4nWA3 mUGEXEysuO3/tTAdyEqHwagI2Bpr4tFZf0ZSQYesvjOKx6X5ogfpZz/czXQ6u2TqXdD9 5/0A== X-Gm-Message-State: AOJu0Yyg3GIzKB1Gs1cdlNNt8vHnZ9GEqatvd+FTuSJRakRz4IT+PCHn JNQymK2iOwAIp+piVpM8W7ZjxQejHGyEiEAIbbbeT21qQTumEPWNgaBWgRtTcETyCMNKGLIczGy ta6k= X-Gm-Gg: ASbGnctNdE6YONXjLwIpNZCkt7ukOCuDWQjHavo3NTl2RUKZrx8pk8+Yg0rPhGCKOrD N5GQfT21/KfYl5u1WuJu3kbnN2RUgnWPWe3eiZtVYoJl+fgXB84vl3WPHawiRBV+PSQsBESUvVr nMki6d9YqoHhVn4Qbwqa1g51RPKiaCMGb48Vr4zUkQbEGoTQy0CnbUkem9NQnToBqSI2no0Kyn9 t04UWQTTKX5BxD9HnToy8FGahwnsxPL0EDNsS9IaY/eWrAKWZRaQ6YT4QtPvBAfBdugCRMNi0C3 lvgBl0ifqANSewhLzBR7/z4D2A== X-Google-Smtp-Source: AGHT+IFkFnOtCkxQDtnDEio8oml8KRXjDA/gtbi5u8j6rmk8/W+XT4uOxbVgISdNpEXOh3R/TNWg/Q== X-Received: by 2002:a05:6a20:4394:b0:1e1:b430:19c6 with SMTP id adf61e73a8af0-1e5e04600e3mr26564657637.10.1735070961814; Tue, 24 Dec 2024 12:09:21 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 62/72] target/hexagon: Use float32_muladd for helper_sffma Date: Tue, 24 Dec 2024 12:05:11 -0800 Message-ID: <20241224200521.310066-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There are no special cases for this instruction. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index d257097091..15b143a568 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -1054,7 +1054,7 @@ float32 HELPER(sffma)(CPUHexagonState *env, float32 RxV, float32 RsV, float32 RtV) { arch_fpop_start(env); - RxV = internal_fmafx(RsV, RtV, RxV, 0, &env->fp_status); + RxV = float32_muladd(RsV, RtV, RxV, 0, &env->fp_status); arch_fpop_end(env); return RxV; } From patchwork Tue Dec 24 20:05:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5325E7718D for ; Tue, 24 Dec 2024 20:10:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBE2-00026H-Eo; Tue, 24 Dec 2024 15:09:54 -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 1tQBDZ-00079L-KD for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:26 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDY-0002zP-1e for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:25 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2162c0f6a39so64892305ad.0 for ; Tue, 24 Dec 2024 12:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070963; x=1735675763; 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=B8Kb81fRDUd8pwBhno+Gknf2gcOv41osiELdqm6o4Ig=; b=Lgt/MJmQ63Xwe+Ac77FMc9sAUEiFoSCxZYYx+EP+aIn2qKkhPVJL3eq/gkLj6YaCqB vr22VTi5Vz/kroWg3TQ/JBuYMkIBWHRpTURSGIYYuI9mdfmjs7BGLzAr+MxYpEOiv92h PyaCA+UmpOPyZYuuBDgvbumQK9Rv3nunQxbeLrL+md6IDY2b0VLYEw6/0y1FHv6EfQy0 d49rq0l+TqTy/CigU7MJk5V39swjMcDD7k+Db1QTMNTcTvr0aBfO8CmnOzo53yv4GVlF 8YAda8VS1aRY7trkAfR/bbaxqvL6C+i6Imxxp0b3Dg2+jTTy+91R3/0RTbkHmYhaDLqs 4fxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070963; x=1735675763; 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=B8Kb81fRDUd8pwBhno+Gknf2gcOv41osiELdqm6o4Ig=; b=YkneBrW6MAdsVkc0udkaN9cmMjtgGv8pOaiDuaGKhEzMRNbBPT5YMi2rQY+9ZPGIXD ruaoxF2mo/IEMrdHGHUMzcg6ay+V3ZbbtiXgSN1q6akJlhgxrFzbXiu8KoGxWw5xPQ7r gt5d4ixosK1y78Pqx9eTLgsoeocMGSIBpcMcRWciLhfazvHjiIcU17j9wQh3T/O1Ho4U rOsRlRJk8ga9ku7t9MVHLmcT1PCK2gE5ZlqWMl65fy2Hm1WN6eQprerZEk63i1+yeCzT VuM+pwaObnYI9cu3mwUmHshpVbv8xJCRFXNLrccLtw4g++2IZ6HdSiYSkTr/A8gWcNM8 H3Tg== X-Gm-Message-State: AOJu0YxDPR3i4cfWa3sFtqvn9xVF0HAyyB2AjEiAwg9z3SuBYUjz78VL KpsjHyAENlEBIue2CQ4SakEmPVV0ZJk4nkdWNsYdotwAGKI4wwo40jheRS+wWGj+gBrtwg+8o71 pEcA= X-Gm-Gg: ASbGncvf0pbHQPmbx8WmlDy/ZKyNecmi1U1S9DRaooZGYPY7viFCx3qyEpc8VUgixy8 BWU5NRdivLHsQeMxW+l1hHZLdyT49fa8YrQf8b3cPoD04W5bj1cJlpgHrayKRDJHLSDrAQvsx4S PXjCsI7abiPPXb9BSK1fGKxLZVWnRjzhVNJSyFTfN+/0tgngHR33B4Pg8bWW3U0o+vXEvOSUH9n ytcYYCNt8lkfgJNA7X/JRbyZQAZT8YennvLyHk7Et091QGv1UHKQDJxZaxbBf24+XVYBggScG0F DezCrgWUS8sURNHSguSIj8+11Q== X-Google-Smtp-Source: AGHT+IHQgSqyKj1Y4aa4cRc35gFRHG5lMPsqgOwxt/+G3QwViO/UYuKvwuK5OFgba/QW6BbIflky/A== X-Received: by 2002:a05:6a00:820c:b0:725:ce39:4516 with SMTP id d2e1a72fcca58-72aa9a3edc8mr28305995b3a.7.1735070962737; Tue, 24 Dec 2024 12:09:22 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 63/72] target/hexagon: Use float32_muladd for helper_sffms Date: Tue, 24 Dec 2024 12:05:12 -0800 Message-ID: <20241224200521.310066-64-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There are no special cases for this instruction. Since hexagon always uses default-nan mode, explicitly negating the first input is unnecessary. Use float_muladd_negate_product instead. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/op_helper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 15b143a568..95bfa5d029 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -1096,10 +1096,9 @@ float32 HELPER(sffma_sc)(CPUHexagonState *env, float32 RxV, float32 HELPER(sffms)(CPUHexagonState *env, float32 RxV, float32 RsV, float32 RtV) { - float32 neg_RsV; arch_fpop_start(env); - neg_RsV = float32_set_sign(RsV, float32_is_neg(RsV) ? 0 : 1); - RxV = internal_fmafx(neg_RsV, RtV, RxV, 0, &env->fp_status); + RxV = float32_muladd(RsV, RtV, RxV, float_muladd_negate_product, + &env->fp_status); arch_fpop_end(env); return RxV; } From patchwork Tue Dec 24 20:05:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920490 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17A2CE77188 for ; Tue, 24 Dec 2024 20:09:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDi-0007bv-62; Tue, 24 Dec 2024 15:09:34 -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 1tQBDb-0007DQ-18 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:27 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDZ-0002ze-Hw for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:26 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-215770613dbso41216155ad.2 for ; Tue, 24 Dec 2024 12:09:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070964; x=1735675764; 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=pM1P4H8kwtouAZ2NoWkwRl0qCbuYni4Pia78By+9+hY=; b=QTp3ms79A+LVU76nAD4T4SzLQpRH75f+g+bJmTfbLlrbbniM5d9/AhIKJokpHfCWe/ ITMe5Bb3IAxG28sRl1FW/uQgeksN5EdBdylAhqRPd8a7ISWbDUW1OzT6QblG/PoC5MA3 ALvd/naTSy8cp/dmjIUDVEvEBFD17Z+T2bpemCCe93tCxjhgGomsm43X2d/5bd0cYcjN mQ8G7ybZ8X3yrWAw3FY2Y3EKXV2evTr8f2JhYa3a2wtz7V13vd7sQJEsMm2BU77w04ZL vfKK4wxxJ6B5u/sf0Dr7cHB2rXbgYYKc0/4COKkhvOMB1W+Y0vAxmzn5tjL/RvjbU+e9 tQ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070964; x=1735675764; 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=pM1P4H8kwtouAZ2NoWkwRl0qCbuYni4Pia78By+9+hY=; b=sCmdn2sl2yi+HkkQQH8aqb6GK+SwU6QAwEj6nqxiHplPcf989AR0mW+daPPd54bnGk NPxHX0lLP47KmYABEK8qKQeC86TNqLjlQnRYodTLuktfc/boo90PikqDXF1galxn2YS3 9pGRb13ppOYVJZ/QI3tKJReGj8SThjGBpe2js0GNBTuJkyuDBo4UpD5NPujZQ2OX8902 rXq6xUNcgt4Q/Vz4F7t/UNJruRuLrAR7eqDwNgZMLx1wZN3YivDTTgN+DUbYf0JvzRzW eA2elNdM7/7JUR4/uo85H75C+Chwd6cMJum91r8Hd+CMOytp+2RQtubAl+px5suc/+gA b+og== X-Gm-Message-State: AOJu0Yw4+Mu7+xKHT8lRc1hpL7EPvu87cIX/l+cIxcp9T3LChq0etV8l MI/uuxCP0zlWyJxHTBKi21h316LQwBBSD5tUkZ+HTtX4QRsi6/26Qw53O5tvU14FIkI3SsLcbaQ queU= X-Gm-Gg: ASbGnctOciuU5qvpcXLDXRj85kgVMLydxTe345QYEP4MsTbp0ITBY/qxxpT2u8+pmLK ybCHi7i44HZkkDzXgU34A2zBJFMV41fkuzM8mZWo/36Dpb3v1sMZnrbM5j+3i2dKVG35Npe1I4m 7536bxqXw4wSMz9h/JOeCO9hY3gUn2oDoKqfaFyRVvgCZ2KUhI/PeA5Sc/wGZa9iBVJwFpNlAmK hGLccbIf9e2eC+x7qLId3CpDn+ed88gt/2KXByM2zqenSD6/rFq/ZqHvKI7zeJNGbGPzsBYIw// 1WzixX1U+ebrzeSaH/Ego8h0tQ== X-Google-Smtp-Source: AGHT+IEPNAkpa+ZAxpg2BfRC8jxoRhCkHmdZVsedT9ZGErNX3et8yx1rHrmXhGchT8VKOwzuGBEy3Q== X-Received: by 2002:a05:6a00:4096:b0:729:c7b:9385 with SMTP id d2e1a72fcca58-72abdd7bdecmr26688209b3a.6.1735070964271; Tue, 24 Dec 2024 12:09:24 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 64/72] target/hexagon: Use float32_muladd_scalbn for helper_sffma_sc Date: Tue, 24 Dec 2024 12:05:13 -0800 Message-ID: <20241224200521.310066-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This instruction has a special case that 0 * x + c returns c without the normal sign folding that comes with 0 + -0. Use the new float_muladd_suppress_add_product_zero to describe this. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/op_helper.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 95bfa5d029..53c65e852e 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -1080,15 +1080,10 @@ static float32 check_nan(float32 dst, float32 x, float_status *fp_status) float32 HELPER(sffma_sc)(CPUHexagonState *env, float32 RxV, float32 RsV, float32 RtV, float32 PuV) { - size4s_t tmp; arch_fpop_start(env); - RxV = check_nan(RxV, RxV, &env->fp_status); - RxV = check_nan(RxV, RsV, &env->fp_status); - RxV = check_nan(RxV, RtV, &env->fp_status); - tmp = internal_fmafx(RsV, RtV, RxV, fSXTN(8, 64, PuV), &env->fp_status); - if (!(float32_is_zero(RxV) && is_zero_prod(RsV, RtV))) { - RxV = tmp; - } + RxV = float32_muladd_scalbn(RsV, RtV, RxV, fSXTN(8, 64, PuV), + float_muladd_suppress_add_product_zero, + &env->fp_status); arch_fpop_end(env); return RxV; } From patchwork Tue Dec 24 20:05:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85DC2E7718E for ; Tue, 24 Dec 2024 20:11:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBEC-0003cw-3u; Tue, 24 Dec 2024 15:10:04 -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 1tQBDb-0007GO-Tt for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:28 -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 1tQBDa-0002zt-6D for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:27 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21636268e43so70684755ad.2 for ; Tue, 24 Dec 2024 12:09:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070965; x=1735675765; 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=nBCIoQniDOPCXed8/3lUiDnf86jkv18W9RdRy76zZxA=; b=EpHfixSyo8Faa66pziac9HuCTWLYbZrwKwE+1+DQKqGgfzNCo0MEyqVYMrVc0jF2LN N8hDBUFA/B5xTo2yF6oXxlK/TF70sDw1FDGf4rKP+gIXTMGdPu4JkWjDqxOpQIxwgVFT kGCuiVQeDCY8MaCqM5tMBwF4qC4HbmFEpcansymcC9I3TKgBVBNRQ50Zs82fvxAO6Tf+ eutoD+ms8bE/HeYsCPGutqCYb5DpJ9dCy4r4zhcJTilMrHn9oEAjUy7V+jjTKxYr0qmA zMB8xgmAB8koaW6ZocK4qHVklowdO7DoJMKsQvmkwja7vWRtr/6yHFpPUvpofYf/6Onc gPdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070965; x=1735675765; 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=nBCIoQniDOPCXed8/3lUiDnf86jkv18W9RdRy76zZxA=; b=GpvF71tyVDeHW6pDcfHSoIY6lyeJWwQ/cCVZ793t7l4ErNnZdjXjaZI9zoFSx+89kB 8fBkuiKWhNciYVITuvb2xynnouP65kujfV5oWSVYGVWJY/eCYpR9vTol9qlih0a7fRzU qU+1nGCx29RaPkJyINaCAcYoNnib+4p/ufbHTUfkWsAI2p7sllAdV54yg0DVrJT+xXZ0 IGpllbO8iTRfMFRNlQ5FxW1NNHnxUOCVXXmHhYiIIw9o/peC7UUivFvbhUQeHSSq6OF6 M/uN6d21QtYBkxlHx3AVWRQyvfwG9gwba7bm+Y1Aaik51pE1Iz8hqFY2tz1SVm/emwuJ r0TA== X-Gm-Message-State: AOJu0YxZYfckSUcHJfu++/uEdgBFb2J6IT+AtEoV/oKKOMzzmAafAZJr b+j4siBBVXrK4vhT7e8QO/PrqEf0QHzbYYpuBAsX/85fc/u+FQQ5YaPq5xXedJBpknH9SVxntIi SZqY= X-Gm-Gg: ASbGncvjpxdV5kdn7/Yy2miZCm9XW/2oQTJumjtUAyQgG6ZsR2tBX5kVqGjUhClqRe2 rGBSzKJtxZdmeLzYJ9hYMjf9lvQEtBBdwXqAX5jg4PZ3lRO/GPyFFaxzP9Xza8c1z5t5GnTIaSO aCY4b+H38Z/X8P7tfpXbG9xxBZ6V63O2zwq735LBfYQAu1GVHt5cdhULaUv6B9P+GTV/hcM9uaY w1oYZ9mhjVLasAirqbJOyEZDqEmyWjf11rNiTca475Q3a9ywVMxjanTnPyPB4h6pTefadctmsxu lS6FMt7ajJP0vdhyE0TzwHiZwQ== X-Google-Smtp-Source: AGHT+IFpT5SJ5/A+GrfOeoK7DQ6JA+b4lWcJPELegzK02zTEKK1ip+FpOUq/IypTa+u+VGNAO1r4Rw== X-Received: by 2002:a05:6a20:6f06:b0:1e1:9ba5:80d8 with SMTP id adf61e73a8af0-1e5e080df22mr25488906637.33.1735070965000; Tue, 24 Dec 2024 12:09:25 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 65/72] target/hexagon: Use float32_muladd for helper_sffm[as]_lib Date: Tue, 24 Dec 2024 12:05:14 -0800 Message-ID: <20241224200521.310066-66-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There are multiple special cases for this instruction. (1) The saturate to normal maximum instead of overflow to infinity is handled by the new float_round_nearest_even_max rounding mode. (2) The 0 * n + c special case is handled by the new float_muladd_suppress_add_product_zero flag. (3) The Inf - Inf -> 0 special case can be detected after the fact by examining float_flag_invalid_isi. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/op_helper.c | 105 +++++++++---------------------------- 1 file changed, 26 insertions(+), 79 deletions(-) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 53c65e852e..6da8db8ea5 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -1059,24 +1059,6 @@ float32 HELPER(sffma)(CPUHexagonState *env, float32 RxV, return RxV; } -static bool is_zero_prod(float32 a, float32 b) -{ - return ((float32_is_zero(a) && is_finite(b)) || - (float32_is_zero(b) && is_finite(a))); -} - -static float32 check_nan(float32 dst, float32 x, float_status *fp_status) -{ - float32 ret = dst; - if (float32_is_any_nan(x)) { - if (extract32(x, 22, 1) == 0) { - float_raise(float_flag_invalid, fp_status); - } - ret = make_float32(0xffffffff); /* nan */ - } - return ret; -} - float32 HELPER(sffma_sc)(CPUHexagonState *env, float32 RxV, float32 RsV, float32 RtV, float32 PuV) { @@ -1098,78 +1080,43 @@ float32 HELPER(sffms)(CPUHexagonState *env, float32 RxV, return RxV; } -static bool is_inf_prod(int32_t a, int32_t b) +static float32 do_sffma_lib(CPUHexagonState *env, float32 RxV, + float32 RsV, float32 RtV, int negate) { - return (float32_is_infinity(a) && float32_is_infinity(b)) || - (float32_is_infinity(a) && is_finite(b) && !float32_is_zero(b)) || - (float32_is_infinity(b) && is_finite(a) && !float32_is_zero(a)); + int flags; + + arch_fpop_start(env); + + set_float_rounding_mode(float_round_nearest_even_max, &env->fp_status); + RxV = float32_muladd(RsV, RtV, RxV, + negate | float_muladd_suppress_add_product_zero, + &env->fp_status); + + flags = get_float_exception_flags(&env->fp_status); + if (flags) { + /* Flags are suppressed by this instruction. */ + set_float_exception_flags(0, &env->fp_status); + + /* Return 0 for Inf - Inf. */ + if (flags & float_flag_invalid_isi) { + RxV = 0; + } + } + + arch_fpop_end(env); + return RxV; } float32 HELPER(sffma_lib)(CPUHexagonState *env, float32 RxV, float32 RsV, float32 RtV) { - bool infinp; - bool infminusinf; - float32 tmp; - - arch_fpop_start(env); - set_float_rounding_mode(float_round_nearest_even, &env->fp_status); - infminusinf = float32_is_infinity(RxV) && - is_inf_prod(RsV, RtV) && - (fGETBIT(31, RsV ^ RxV ^ RtV) != 0); - infinp = float32_is_infinity(RxV) || - float32_is_infinity(RtV) || - float32_is_infinity(RsV); - RxV = check_nan(RxV, RxV, &env->fp_status); - RxV = check_nan(RxV, RsV, &env->fp_status); - RxV = check_nan(RxV, RtV, &env->fp_status); - tmp = internal_fmafx(RsV, RtV, RxV, 0, &env->fp_status); - if (!(float32_is_zero(RxV) && is_zero_prod(RsV, RtV))) { - RxV = tmp; - } - set_float_exception_flags(0, &env->fp_status); - if (float32_is_infinity(RxV) && !infinp) { - RxV = RxV - 1; - } - if (infminusinf) { - RxV = 0; - } - arch_fpop_end(env); - return RxV; + return do_sffma_lib(env, RxV, RsV, RtV, 0); } float32 HELPER(sffms_lib)(CPUHexagonState *env, float32 RxV, float32 RsV, float32 RtV) { - bool infinp; - bool infminusinf; - float32 tmp; - - arch_fpop_start(env); - set_float_rounding_mode(float_round_nearest_even, &env->fp_status); - infminusinf = float32_is_infinity(RxV) && - is_inf_prod(RsV, RtV) && - (fGETBIT(31, RsV ^ RxV ^ RtV) == 0); - infinp = float32_is_infinity(RxV) || - float32_is_infinity(RtV) || - float32_is_infinity(RsV); - RxV = check_nan(RxV, RxV, &env->fp_status); - RxV = check_nan(RxV, RsV, &env->fp_status); - RxV = check_nan(RxV, RtV, &env->fp_status); - float32 minus_RsV = float32_sub(float32_zero, RsV, &env->fp_status); - tmp = internal_fmafx(minus_RsV, RtV, RxV, 0, &env->fp_status); - if (!(float32_is_zero(RxV) && is_zero_prod(RsV, RtV))) { - RxV = tmp; - } - set_float_exception_flags(0, &env->fp_status); - if (float32_is_infinity(RxV) && !infinp) { - RxV = RxV - 1; - } - if (infminusinf) { - RxV = 0; - } - arch_fpop_end(env); - return RxV; + return do_sffma_lib(env, RxV, RsV, RtV, float_muladd_negate_product); } float64 HELPER(dfmpyfix)(CPUHexagonState *env, float64 RssV, float64 RttV) From patchwork Tue Dec 24 20:05:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87A0AE77188 for ; Tue, 24 Dec 2024 20:18:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBE8-00035Z-B4; Tue, 24 Dec 2024 15:10:00 -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 1tQBDd-0007My-64 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:29 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDb-000308-AN for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:28 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-21631789fcdso47000835ad.1 for ; Tue, 24 Dec 2024 12:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070966; x=1735675766; 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=dy+3YRybYCVi0eIJERcGpwApxyCnVCsmSJWB/vHW2XY=; b=NgTKV4knx93IpOboC1wfD3xgDIY27mRt9vFeqAfMatOPhyRjeMQ2WxOd4KbiWuRPV3 YAO2dbCm9mXqQSAMXnrsKx8l+YPlUKLwHzp9yiLyJk1k84YNeZGQtXqaf+c53E6xzyO8 cK+uEu+FMu7oDQT1t1zVxibuBNbT67RRhLrIxEUCFeY6tjdYo6J4oSK5yJyKc/26mTsI qE3u5wbT2u9hL3nvL6ZVJE0lJ8ckxuVBy6PTJI2qrXgOMAYKhET45V9Hx1SpfQZeVn7j e2R+BxdG+hF2bM3Ze3LdOMsFEZZ8naxBCtPvDtodS7FCgPNSiXDVzhvGHjX0btnSeSoZ m22Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070966; x=1735675766; 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=dy+3YRybYCVi0eIJERcGpwApxyCnVCsmSJWB/vHW2XY=; b=oYQYdyeQEqqTerpNd8VGUwx296gTBhvccsOUKOZZyByc2Bgk6Q5VxJQVjJR1MXwt1j +sp+fYREQoWX9475pW/Swu/QE/G5sPZxgWm9ywHTxu0nTAqo21Y8DcHdlO9a4PdUrWhO Y5lZQ8Sa+9xdLBz6a4+YEb+HjvOs6pXH0QeVhPm1wuCXAtvG2Xk0Y6ZS/wrpw/+k3DrE Dr0n5yyirG6oO3K9Dv9V5lR9r55cTcsS1l0/vDDE3zr66PvCHVkaoc/Xu4R0x+OYHdPL nmeo6YXKPVTK+fWYf/NeOSwhyK6Afc7BMVziAALeKQtrJ+C31VQxQPZQC15C5ZGrj6rd 4oxg== X-Gm-Message-State: AOJu0YwqfzPrGThAGQTPj84MjH6tr0yMN6EW2lzAkDUK7tWxp7B0qrps cCmQzGz+Fv3eTjaZaRFtjOM1pa5BofZ9i+ml/sEHuhl5N+U62DZKSg4DzrEPh2amvxdttD6T/rM TLJU= X-Gm-Gg: ASbGncu2jeb7OcvSdFl6BSJA3TQb01hg5ImrakFnXITe3BjE2A2IrOafapfkE7GB1W1 2Kf+nQ/9eU2bdcanKgJwhUO044Pqp3WDHG2YJK2OfqjDOOw6ZVJrowzgsScfEBVx6tjmrs0TIuM jJDadhGBG3gmY8yvmrL+0o7EL3TRlHqfrnJ0/8qfhzbVgghBptjU9QhRqSzhtpPlY0ycqTwX+dk qnL1rLeXrFRpDKrYFUG/+CuzTxpEBaUX0CP6D5Ufiwt4qRumZTxDA1WcznDqLqJL1PWi375vvD1 g4ZKjZBaEyXqs9VDKTbXjjmKEg== X-Google-Smtp-Source: AGHT+IEw9hC0XBUPFtpYgT3ZANGWc/E/lW5OflDA+M4jKLCydW418qCwGvSuNjCKW3IPuSzGHws5Kw== X-Received: by 2002:a05:6a21:3989:b0:1d9:a94:feec with SMTP id adf61e73a8af0-1e5e1e0460bmr29793862637.2.1735070965943; Tue, 24 Dec 2024 12:09:25 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 66/72] target/hexagon: Remove internal_fmafx Date: Tue, 24 Dec 2024 12:05:15 -0800 Message-ID: <20241224200521.310066-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The function is now unused. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.h | 2 - target/hexagon/fma_emu.c | 171 --------------------------------------- 2 files changed, 173 deletions(-) diff --git a/target/hexagon/fma_emu.h b/target/hexagon/fma_emu.h index ad5df5d038..fed054b609 100644 --- a/target/hexagon/fma_emu.h +++ b/target/hexagon/fma_emu.h @@ -30,8 +30,6 @@ static inline uint32_t float32_getexp_raw(float32 f32) } int32_t float32_getexp(float32 f32); float32 infinite_float32(uint8_t sign); -float32 internal_fmafx(float32 a, float32 b, float32 c, - int scale, float_status *fp_status); float64 internal_mpyhh(float64 a, float64 b, unsigned long long int accumulated, float_status *fp_status); diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index 35971b8b99..0c7c7f636c 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -90,21 +90,6 @@ int32_t float64_getexp(float64 f64) return -1; } -static uint64_t float32_getmant(float32 f32) -{ - Float a = { .i = f32 }; - if (float32_is_normal(f32)) { - return a.mant | 1ULL << 23; - } - if (float32_is_zero(f32)) { - return 0; - } - if (float32_is_denormal(f32)) { - return a.mant; - } - return ~0ULL; -} - int32_t float32_getexp(float32 f32) { Float a = { .i = f32 }; @@ -369,25 +354,6 @@ float32 infinite_float32(uint8_t sign) } /* Return a maximum finite value with the requested sign */ -static float32 maxfinite_float32(uint8_t sign) -{ - if (sign) { - return make_float32(SF_MINUS_MAXF); - } else { - return make_float32(SF_MAXF); - } -} - -/* Return a zero value with requested sign */ -static float32 zero_float32(uint8_t sign) -{ - if (sign) { - return make_float32(0x80000000); - } else { - return float32_zero; - } -} - #define GEN_XF_ROUND(SUFFIX, MANTBITS, INF_EXP, INTERNAL_TYPE) \ static SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \ { \ @@ -517,143 +483,6 @@ static SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \ } GEN_XF_ROUND(float64, DF_MANTBITS, DF_INF_EXP, Double) -GEN_XF_ROUND(float32, SF_MANTBITS, SF_INF_EXP, Float) - -static bool is_inf_prod(float64 a, float64 b) -{ - return ((float64_is_infinity(a) && float64_is_infinity(b)) || - (float64_is_infinity(a) && is_finite(b) && (!float64_is_zero(b))) || - (float64_is_infinity(b) && is_finite(a) && (!float64_is_zero(a)))); -} - -static float64 special_fma(float64 a, float64 b, float64 c, - float_status *fp_status) -{ - float64 ret = make_float64(0); - - /* - * If A multiplied by B is an exact infinity and C is also an infinity - * but with the opposite sign, FMA returns NaN and raises invalid. - */ - uint8_t a_sign = float64_is_neg(a); - uint8_t b_sign = float64_is_neg(b); - uint8_t c_sign = float64_is_neg(c); - if (is_inf_prod(a, b) && float64_is_infinity(c)) { - if ((a_sign ^ b_sign) != c_sign) { - ret = make_float64(DF_NAN); - float_raise(float_flag_invalid, fp_status); - return ret; - } - } - if ((float64_is_infinity(a) && float64_is_zero(b)) || - (float64_is_zero(a) && float64_is_infinity(b))) { - ret = make_float64(DF_NAN); - float_raise(float_flag_invalid, fp_status); - return ret; - } - /* - * If none of the above checks are true and C is a NaN, - * a NaN shall be returned - * If A or B are NaN, a NAN shall be returned. - */ - if (float64_is_any_nan(a) || - float64_is_any_nan(b) || - float64_is_any_nan(c)) { - if (float64_is_any_nan(a) && (fGETBIT(51, a) == 0)) { - float_raise(float_flag_invalid, fp_status); - } - if (float64_is_any_nan(b) && (fGETBIT(51, b) == 0)) { - float_raise(float_flag_invalid, fp_status); - } - if (float64_is_any_nan(c) && (fGETBIT(51, c) == 0)) { - float_raise(float_flag_invalid, fp_status); - } - ret = make_float64(DF_NAN); - return ret; - } - /* - * We have checked for adding opposite-signed infinities. - * Other infinities return infinity with the correct sign - */ - if (float64_is_infinity(c)) { - ret = infinite_float64(c_sign); - return ret; - } - if (float64_is_infinity(a) || float64_is_infinity(b)) { - ret = infinite_float64(a_sign ^ b_sign); - return ret; - } - g_assert_not_reached(); -} - -static float32 special_fmaf(float32 a, float32 b, float32 c, - float_status *fp_status) -{ - float64 aa, bb, cc; - aa = float32_to_float64(a, fp_status); - bb = float32_to_float64(b, fp_status); - cc = float32_to_float64(c, fp_status); - return float64_to_float32(special_fma(aa, bb, cc, fp_status), fp_status); -} - -float32 internal_fmafx(float32 a, float32 b, float32 c, int scale, - float_status *fp_status) -{ - Accum prod; - Accum acc; - Accum result; - accum_init(&prod); - accum_init(&acc); - accum_init(&result); - - uint8_t a_sign = float32_is_neg(a); - uint8_t b_sign = float32_is_neg(b); - uint8_t c_sign = float32_is_neg(c); - if (float32_is_infinity(a) || - float32_is_infinity(b) || - float32_is_infinity(c)) { - return special_fmaf(a, b, c, fp_status); - } - if (float32_is_any_nan(a) || - float32_is_any_nan(b) || - float32_is_any_nan(c)) { - return special_fmaf(a, b, c, fp_status); - } - if ((scale == 0) && (float32_is_zero(a) || float32_is_zero(b))) { - float32 tmp = float32_mul(a, b, fp_status); - tmp = float32_add(tmp, c, fp_status); - return tmp; - } - - /* (a * 2**b) * (c * 2**d) == a*c * 2**(b+d) */ - prod.mant = int128_mul_6464(float32_getmant(a), float32_getmant(b)); - - /* - * Note: extracting the mantissa into an int is multiplying by - * 2**23, so adjust here - */ - prod.exp = float32_getexp(a) + float32_getexp(b) - SF_BIAS - 23; - prod.sign = a_sign ^ b_sign; - if (float32_is_zero(a) || float32_is_zero(b)) { - prod.exp = -2 * WAY_BIG_EXP; - } - if ((scale > 0) && float32_is_denormal(c)) { - acc.mant = int128_mul_6464(0, 0); - acc.exp = -WAY_BIG_EXP; - acc.sign = c_sign; - acc.sticky = 1; - result = accum_add(prod, acc); - } else if (!float32_is_zero(c)) { - acc.mant = int128_mul_6464(float32_getmant(c), 1); - acc.exp = float32_getexp(c); - acc.sign = c_sign; - result = accum_add(prod, acc); - } else { - result = prod; - } - result.exp += scale; - return accum_round_float32(result, fp_status); -} float64 internal_mpyhh(float64 a, float64 b, unsigned long long int accumulated, From patchwork Tue Dec 24 20:05:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFEEEE77188 for ; Tue, 24 Dec 2024 20:09:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBE2-0002GU-P2; Tue, 24 Dec 2024 15:09:54 -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 1tQBDe-0007Rc-UB for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:31 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDc-00030L-Fw for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:30 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2161eb95317so58726815ad.1 for ; Tue, 24 Dec 2024 12:09:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070967; x=1735675767; 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=VTkbR01xtg3cDFd0zyp26LRPzyNskPHkgWCn6SCa0AE=; b=I48sZ0fa0E6WgeRWAJUJ9ayu5wg2OiF8jY2rhPLjBf0ixPyqICXd+oye8dgYPkOykk RnIWHYzKGwjq5t/0egSyQNHdInJjngpp9EkoPmOf3U3GAh4dnoa8Zm3egDnefGSYSHKv lrZx5xVSc28ir3HQXPudeP/WOQw7QUUl3V8DKX2ajQqzB5TPlcRgK3Qs30Iu9JWIX3rT ejHLBkTegQzsfGk4BY7AlBHAKYDF2FZV5OzjrES9POnfiP7zRkO0LDcuXlQ+Qk18YrUu V38qymSeUVRYITNJj6f3V3nLxgD8HF3c7quy4TukEuHhPfjE682Rn1WgTmwzbKAzU7Fc bjug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070967; x=1735675767; 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=VTkbR01xtg3cDFd0zyp26LRPzyNskPHkgWCn6SCa0AE=; b=ON2dbLb3MvSoC/3I53bhX6769ydzOKqGnlb4tZHFluTu/kvWX2W2UOXQjEsPDasO/A 7TCthvtX4FH8ShIlouxg7FM10IvCJtqJ9napyi7ut+IMfNj2519EJda1INXUTVmFTWvN cnE3aOxIFmuyuWgeQ9+OnS3urMPcqdCf9MaWnMw9XAszyai1MpBpDGvh6sYBBgAJhpQT +Zpiq7TX9A2oTCnJPDgCD1ZhtSVs3hWBm0WCLP+MV4QEaA7UoqvsT3S79VqQXZu9z4WW pW7IkdMmjbYOkWAIxPcAed3gixlXQcJjre/SESjvOf7h1QjBiq8nlokkvoVVljJKVR8f 168Q== X-Gm-Message-State: AOJu0YzRLPyoGEWpLPIWQH35/IQjUFDL3aeXOdbMjiJGS//0LtP+8LKW lkLNF0siPMETUaPmEcbyTWEiPs5SQOmETfr7q0K4AVnF6OeOT5ZOTSYzTu5xDo50oWNSDYwg8UW Lq3U= X-Gm-Gg: ASbGncuDcta8kgEdZPAjMGrhQ4YdnaTISr4lGQS6NtCYHNPR+qDsoP9ee2TMnaMBMSt G+2M66Zl9JMR1hhOi840F7UYoNUEZ1Q0fYxFmizwopJMDtvvWIvDSszK7rWIM+mTjoqCWWLLORX 75li3m/iIsXGuMIwwO5PUhLhjGm3wBpnWBc66qNuBKOWIBKXBsossCmkTyPblPjnu6byTcisOMq 85nw/6ENLeYM8XUh8WMRV1/oRpD4oanzpE51purTRMa4rARcGWcRHQmjhQpSlGURvOdlqcdhBGS EfMGs4u+hwSUGTT9fmakYffc3g== X-Google-Smtp-Source: AGHT+IHlgMGlXIvO07w0oWufQLrdbGA2bPMq6EX7uvx79Dbz9wWz+y78ypyHiSEKplDmmsJKpNYrBg== X-Received: by 2002:a05:6a21:900e:b0:1db:ec0f:5cf4 with SMTP id adf61e73a8af0-1e5e081c8bbmr27968235637.39.1735070967175; Tue, 24 Dec 2024 12:09:27 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 67/72] target/hexagon: Expand GEN_XF_ROUND Date: Tue, 24 Dec 2024 12:05:16 -0800 Message-ID: <20241224200521.310066-68-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This massive macro is now only used once. Expand it for use only by float64. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.c | 255 +++++++++++++++++++-------------------- 1 file changed, 127 insertions(+), 128 deletions(-) diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index 0c7c7f636c..0769de43de 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -354,136 +354,135 @@ float32 infinite_float32(uint8_t sign) } /* Return a maximum finite value with the requested sign */ -#define GEN_XF_ROUND(SUFFIX, MANTBITS, INF_EXP, INTERNAL_TYPE) \ -static SUFFIX accum_round_##SUFFIX(Accum a, float_status * fp_status) \ -{ \ - if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0) \ - && ((a.guard | a.round | a.sticky) == 0)) { \ - /* result zero */ \ - switch (fp_status->float_rounding_mode) { \ - case float_round_down: \ - return zero_##SUFFIX(1); \ - default: \ - return zero_##SUFFIX(0); \ - } \ - } \ - /* Normalize right */ \ - /* We want MANTBITS bits of mantissa plus the leading one. */ \ - /* That means that we want MANTBITS+1 bits, or 0x000000000000FF_FFFF */ \ - /* So we need to normalize right while the high word is non-zero and \ - * while the low word is nonzero when masked with 0xffe0_0000_0000_0000 */ \ - while ((int128_gethi(a.mant) != 0) || \ - ((int128_getlo(a.mant) >> (MANTBITS + 1)) != 0)) { \ - a = accum_norm_right(a, 1); \ - } \ - /* \ - * OK, now normalize left \ - * We want to normalize left until we have a leading one in bit 24 \ - * Theoretically, we only need to shift a maximum of one to the left if we \ - * shifted out lots of bits from B, or if we had no shift / 1 shift sticky \ - * should be 0 \ - */ \ - while ((int128_getlo(a.mant) & (1ULL << MANTBITS)) == 0) { \ - a = accum_norm_left(a); \ - } \ - /* \ - * OK, now we might need to denormalize because of potential underflow. \ - * We need to do this before rounding, and rounding might make us normal \ - * again \ - */ \ - while (a.exp <= 0) { \ - a = accum_norm_right(a, 1 - a.exp); \ - /* \ - * Do we have underflow? \ - * That's when we get an inexact answer because we ran out of bits \ - * in a denormal. \ - */ \ - if (a.guard || a.round || a.sticky) { \ - float_raise(float_flag_underflow, fp_status); \ - } \ - } \ - /* OK, we're relatively canonical... now we need to round */ \ - if (a.guard || a.round || a.sticky) { \ - float_raise(float_flag_inexact, fp_status); \ - switch (fp_status->float_rounding_mode) { \ - case float_round_to_zero: \ - /* Chop and we're done */ \ - break; \ - case float_round_up: \ - if (a.sign == 0) { \ - a.mant = int128_add(a.mant, int128_one()); \ - } \ - break; \ - case float_round_down: \ - if (a.sign != 0) { \ - a.mant = int128_add(a.mant, int128_one()); \ - } \ - break; \ - default: \ - if (a.round || a.sticky) { \ - /* round up if guard is 1, down if guard is zero */ \ - a.mant = int128_add(a.mant, int128_make64(a.guard)); \ - } else if (a.guard) { \ - /* exactly .5, round up if odd */ \ - a.mant = int128_add(a.mant, int128_and(a.mant, int128_one())); \ - } \ - break; \ - } \ - } \ - /* \ - * OK, now we might have carried all the way up. \ - * So we might need to shr once \ - * at least we know that the lsb should be zero if we rounded and \ - * got a carry out... \ - */ \ - if ((int128_getlo(a.mant) >> (MANTBITS + 1)) != 0) { \ - a = accum_norm_right(a, 1); \ - } \ - /* Overflow? */ \ - if (a.exp >= INF_EXP) { \ - /* Yep, inf result */ \ - float_raise(float_flag_overflow, fp_status); \ - float_raise(float_flag_inexact, fp_status); \ - switch (fp_status->float_rounding_mode) { \ - case float_round_to_zero: \ - return maxfinite_##SUFFIX(a.sign); \ - case float_round_up: \ - if (a.sign == 0) { \ - return infinite_##SUFFIX(a.sign); \ - } else { \ - return maxfinite_##SUFFIX(a.sign); \ - } \ - case float_round_down: \ - if (a.sign != 0) { \ - return infinite_##SUFFIX(a.sign); \ - } else { \ - return maxfinite_##SUFFIX(a.sign); \ - } \ - default: \ - return infinite_##SUFFIX(a.sign); \ - } \ - } \ - /* Underflow? */ \ - if (int128_getlo(a.mant) & (1ULL << MANTBITS)) { \ - /* Leading one means: No, we're normal. So, we should be done... */ \ - INTERNAL_TYPE ret; \ - ret.i = 0; \ - ret.sign = a.sign; \ - ret.exp = a.exp; \ - ret.mant = int128_getlo(a.mant); \ - return ret.i; \ - } \ - assert(a.exp == 1); \ - INTERNAL_TYPE ret; \ - ret.i = 0; \ - ret.sign = a.sign; \ - ret.exp = 0; \ - ret.mant = int128_getlo(a.mant); \ - return ret.i; \ +static float64 accum_round_float64(Accum a, float_status *fp_status) +{ + if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0) + && ((a.guard | a.round | a.sticky) == 0)) { + /* result zero */ + switch (fp_status->float_rounding_mode) { + case float_round_down: + return zero_float64(1); + default: + return zero_float64(0); + } + } + /* + * Normalize right + * We want DF_MANTBITS bits of mantissa plus the leading one. + * That means that we want DF_MANTBITS+1 bits, or 0x000000000000FF_FFFF + * So we need to normalize right while the high word is non-zero and + * while the low word is nonzero when masked with 0xffe0_0000_0000_0000 + */ + while ((int128_gethi(a.mant) != 0) || + ((int128_getlo(a.mant) >> (DF_MANTBITS + 1)) != 0)) { + a = accum_norm_right(a, 1); + } + /* + * OK, now normalize left + * We want to normalize left until we have a leading one in bit 24 + * Theoretically, we only need to shift a maximum of one to the left if we + * shifted out lots of bits from B, or if we had no shift / 1 shift sticky + * should be 0 + */ + while ((int128_getlo(a.mant) & (1ULL << DF_MANTBITS)) == 0) { + a = accum_norm_left(a); + } + /* + * OK, now we might need to denormalize because of potential underflow. + * We need to do this before rounding, and rounding might make us normal + * again + */ + while (a.exp <= 0) { + a = accum_norm_right(a, 1 - a.exp); + /* + * Do we have underflow? + * That's when we get an inexact answer because we ran out of bits + * in a denormal. + */ + if (a.guard || a.round || a.sticky) { + float_raise(float_flag_underflow, fp_status); + } + } + /* OK, we're relatively canonical... now we need to round */ + if (a.guard || a.round || a.sticky) { + float_raise(float_flag_inexact, fp_status); + switch (fp_status->float_rounding_mode) { + case float_round_to_zero: + /* Chop and we're done */ + break; + case float_round_up: + if (a.sign == 0) { + a.mant = int128_add(a.mant, int128_one()); + } + break; + case float_round_down: + if (a.sign != 0) { + a.mant = int128_add(a.mant, int128_one()); + } + break; + default: + if (a.round || a.sticky) { + /* round up if guard is 1, down if guard is zero */ + a.mant = int128_add(a.mant, int128_make64(a.guard)); + } else if (a.guard) { + /* exactly .5, round up if odd */ + a.mant = int128_add(a.mant, int128_and(a.mant, int128_one())); + } + break; + } + } + /* + * OK, now we might have carried all the way up. + * So we might need to shr once + * at least we know that the lsb should be zero if we rounded and + * got a carry out... + */ + if ((int128_getlo(a.mant) >> (DF_MANTBITS + 1)) != 0) { + a = accum_norm_right(a, 1); + } + /* Overflow? */ + if (a.exp >= DF_INF_EXP) { + /* Yep, inf result */ + float_raise(float_flag_overflow, fp_status); + float_raise(float_flag_inexact, fp_status); + switch (fp_status->float_rounding_mode) { + case float_round_to_zero: + return maxfinite_float64(a.sign); + case float_round_up: + if (a.sign == 0) { + return infinite_float64(a.sign); + } else { + return maxfinite_float64(a.sign); + } + case float_round_down: + if (a.sign != 0) { + return infinite_float64(a.sign); + } else { + return maxfinite_float64(a.sign); + } + default: + return infinite_float64(a.sign); + } + } + /* Underflow? */ + if (int128_getlo(a.mant) & (1ULL << DF_MANTBITS)) { + /* Leading one means: No, we're normal. So, we should be done... */ + Double ret; + ret.i = 0; + ret.sign = a.sign; + ret.exp = a.exp; + ret.mant = int128_getlo(a.mant); + return ret.i; + } + assert(a.exp == 1); + Double ret; + ret.i = 0; + ret.sign = a.sign; + ret.exp = 0; + ret.mant = int128_getlo(a.mant); + return ret.i; } -GEN_XF_ROUND(float64, DF_MANTBITS, DF_INF_EXP, Double) - float64 internal_mpyhh(float64 a, float64 b, unsigned long long int accumulated, float_status *fp_status) From patchwork Tue Dec 24 20:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56C9AE7718D for ; Tue, 24 Dec 2024 20:17:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDv-0001F3-Rp; Tue, 24 Dec 2024 15:09:48 -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 1tQBDf-0007TQ-Er for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:31 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDd-00030Y-UK for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:31 -0500 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2ee397a82f6so5866840a91.2 for ; Tue, 24 Dec 2024 12:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070968; x=1735675768; 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=RKTTrx8B/icquGiBXqUA5XkQlJqGmYAEi37JaPi9ziQ=; b=FBjx8nIWslRurdSEhHxyqL00uZZjCLvPBbPOZ/K1wXFUgH5X3d61Je5wnD8Tx55Pf/ zD/8lLWJfWKW1iWyNtDBW1tPY5GRs7DKXS28fFzV9NlEhwrhSYDDSd7bsqCV6NkAQiPT V0Q2IUcq7KAP5J6uGpuQ6WHTH5p+CTAvVzo7gtWRglMhF3/h3/Hbi92Og6PjKsr2QkX5 ubV3hSmPHmcQLgm/NfydpDJuWojIgE/QSj2tewTT7qd0fGMUV8a1oceRoCsC4AuwnTip CHLL+lhZKgj8LsqN0bMGttZEmGHB0xbMdYCDw1oOzUwN8H0DjA+vMne20ZlwSHOpp4a7 kICw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070968; x=1735675768; 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=RKTTrx8B/icquGiBXqUA5XkQlJqGmYAEi37JaPi9ziQ=; b=uXv7eQcUNplo7HsSBMZtENa2xdfiz01N/ke3wf1JZvqgqX2B2xOLjIbQXwhW4rmT38 EDWAJ85YSWFxCYjMDdWV5KG7WbuUEP7mpm99COxhb0MRKJD3izBkqgBLn4R5SZfOIcD7 GuyS6g0fZbuZBmB8Mt9DxoOIgR75WKx4EU3WRsIBs87mwQp84H+BjhQjJBjjku3kkWrc BnKJ6seBttkaJje5LRGkfFoqY6XECTbJl5Vwjzw9hPdh11PRg/ToQnFdReoF0PpS1Cr3 SIMUJNAcBFJ3hipxHpiyWg6N64gyH5vmy17qteLu3RmPzBAzLOfdaprKM/XHe56pr01v Q8rQ== X-Gm-Message-State: AOJu0YyHWRgHUQGri8Pi5feWYy6wS6RB8zqVnkcGHRTR7FD4ABJBEXKI H1WRVPXSkEE3UNoRTzcuxu6UgeCdswAS7CMWXIF6NZazSjbkHC9vSP1D664zATy38dmCpxv9A61 XVhU= X-Gm-Gg: ASbGncuCj2vPSVDU8iqbFdXoQTJywUzGV8pCeo10UpUQLZ0L8gXlfc7r4KaRK5jyCpH 0qBGymPmRe2BrLQA9eVPR3NCDyV3RRZFdJ5sphGK2gkUUyRiaTaYQSygFnCY78xj2Sjr5yoirRw 5rTJShfaMPeecsuMHvCRp5R5ZfMBKuxDXDvVTQUzFU7GSGUvwz2ZQ2bBOaN3ooaSyVZBVSGqDcN s1R7SJKGuqn5LJC5HPYDifIn1d4JJW75R4r6wB3/s1tj+DnNBRg/5A9VMyLiV4h1UaIDZsj/MQl QBXc6OlTe8hQfIacDkTwuZnrxw== X-Google-Smtp-Source: AGHT+IH8sBYGma8KW8VFaxhKiL5C8+1aN2Cn4B0G1vI+xbm+lJt8SEGmeb5MDNMzyJNrybxDsKioXw== X-Received: by 2002:a05:6a20:8427:b0:1e0:ca95:3cb2 with SMTP id adf61e73a8af0-1e5e0458eb9mr32037304637.8.1735070968572; Tue, 24 Dec 2024 12:09:28 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 68/72] target/hexagon: Remove Float Date: Tue, 24 Dec 2024 12:05:17 -0800 Message-ID: <20241224200521.310066-69-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This structure, with bitfields, is incorrect for big-endian. Use the existing float32_getexp_raw which uses extract32. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index 0769de43de..2a8f72fee3 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -53,16 +53,6 @@ typedef union { }; } Double; -typedef union { - float f; - uint32_t i; - struct { - uint32_t mant:23; - uint32_t exp:8; - uint32_t sign:1; - }; -} Float; - static uint64_t float64_getmant(float64 f64) { Double a = { .i = f64 }; @@ -92,12 +82,12 @@ int32_t float64_getexp(float64 f64) int32_t float32_getexp(float32 f32) { - Float a = { .i = f32 }; + int exp = float32_getexp_raw(f32); if (float32_is_normal(f32)) { - return a.exp; + return exp; } if (float32_is_denormal(f32)) { - return a.exp + 1; + return exp + 1; } return -1; } From patchwork Tue Dec 24 20:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2A6BE7718D for ; Tue, 24 Dec 2024 20:14:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDz-0001eE-T7; Tue, 24 Dec 2024 15:09:52 -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 1tQBDg-0007Wn-Qr for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:33 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDf-00030k-0U for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:32 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21675fd60feso73587425ad.2 for ; Tue, 24 Dec 2024 12:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070969; x=1735675769; 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=zmgwYYyv+juXwg/CgaDAXGKo2B+5k9ACWJHCK3pXUJ4=; b=HL7R1URW8hSYKtS8mqC7XPJm3HLZ53Ggibg5hmtTiG9DAUnzfRO0iU9khoiSQc4hd/ hZyFzx3aoyThexULHkC7cvtJiyUs8mFxW+X49ulvEwmpFmBchctfWVbozd1Njf1LODyw 7L2Wc3oT6rGqlQMgltMDDEeejCHpcbRWlVf3PmXjytR6k6R5xhh7QCbOrvjcOjmFCc6G iVMXIdv2+W1yrzwQ9LysXOdplZezbq6LgjgQVTunz04ZtNBGKgW8Ulw29PUIvAtcy/SJ ItBjMotDVWDiA4a1sHEuX3kx79w+p4A+xDKK8HbnIuvOUrOXCk0dcznY0N0FB06garrE h3AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070969; x=1735675769; 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=zmgwYYyv+juXwg/CgaDAXGKo2B+5k9ACWJHCK3pXUJ4=; b=bUCIX/elFqyw1NGyrEEkBVzOzW1q1IXpk5McZ0HZDBGZZt4I52odqV25/CSSxE6Q2k moe9ovb9gwR3ERDzxg8hbbjUwIUkvBib/mwtNMo9vkJYoaWYVulkmTpMa6ljwGh5DCra dU7Qnl2xqSHiFmP9T0UMrzXEPt0whb9HgVluOqSRemSrU43qVQDXX/h8fVmGqvO+bGlP MX2FtYTH4EA+RxxGgUuRTXRMPZ/uOzHhpSwDQARh5zxCqDNHra+cZmDYwKpjuydm3qpp gbfy/46r2OV8WS9bNBRHAC5Q6qN0OToZC3HY8f+5tPLhDjfqSfB9M4bDALGBsqcZ6XGS Whmw== X-Gm-Message-State: AOJu0YxT66L0OjJCJFWQmkZ1P6cQ2ghN3ZLdV6wW+0h4KeD+5TBea5NF CusoX8hkHsCMPAls4CzqWRQ6P83SAcY/+btcZxv5e1xTaqxYWrfvRrFoUcx0rxkFB3CRNsqxmdc vT9o= X-Gm-Gg: ASbGncuYRURORK0eSSBDvjkuasB1wMc1ivOmi/9WyhDHaiUidN/hS1j4QBu0JMJR0im bFGUMsLU4UbMDaT7CTFrWDBG6mq3ap1JfExvrlPGdUlnJkheRPP2WoYpwHDX2zwz0ybTzyLLvdF 9h10i8mPbb4OQ1IX7dlbLU2ZsKG06aGi8UD2cb6i610YX4eK2jUmpBkm1ioZ10At5rQG2NYDLVY 9XuifzvAWVGy8HHdhndqtOz+y2tnB5tZUyAF/KPR91yr2m07QCfErrzHE1E9/prJRpSPeoXH9Ey ZKm+XAgN+ChzndBBvch4ItEUbA== X-Google-Smtp-Source: AGHT+IEVS2yGwfGET3F2CBJPDM2m79vZwPbnMFrTSEP3CxXiTjd2wu9Cv4QqN4W5YysirLJP6kWvFQ== X-Received: by 2002:a05:6a20:7289:b0:1e0:d4f4:5b39 with SMTP id adf61e73a8af0-1e5e04a0ee8mr31050261637.24.1735070969558; Tue, 24 Dec 2024 12:09:29 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 69/72] target/hexagon: Remove Double Date: Tue, 24 Dec 2024 12:05:18 -0800 Message-ID: <20241224200521.310066-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This structure, with bitfields, is incorrect for big-endian. Use extract64 and deposit64 instead. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.c | 46 ++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index 2a8f72fee3..ddc793fe14 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -43,39 +43,29 @@ #define WAY_BIG_EXP 4096 -typedef union { - double f; - uint64_t i; - struct { - uint64_t mant:52; - uint64_t exp:11; - uint64_t sign:1; - }; -} Double; - static uint64_t float64_getmant(float64 f64) { - Double a = { .i = f64 }; + uint64_t mant = extract64(f64, 0, 52); if (float64_is_normal(f64)) { - return a.mant | 1ULL << 52; + return mant | 1ULL << 52; } if (float64_is_zero(f64)) { return 0; } if (float64_is_denormal(f64)) { - return a.mant; + return mant; } return ~0ULL; } int32_t float64_getexp(float64 f64) { - Double a = { .i = f64 }; + int exp = extract64(f64, 52, 11); if (float64_is_normal(f64)) { - return a.exp; + return exp; } if (float64_is_denormal(f64)) { - return a.exp + 1; + return exp + 1; } return -1; } @@ -346,6 +336,8 @@ float32 infinite_float32(uint8_t sign) /* Return a maximum finite value with the requested sign */ static float64 accum_round_float64(Accum a, float_status *fp_status) { + uint64_t ret; + if ((int128_gethi(a.mant) == 0) && (int128_getlo(a.mant) == 0) && ((a.guard | a.round | a.sticky) == 0)) { /* result zero */ @@ -455,22 +447,16 @@ static float64 accum_round_float64(Accum a, float_status *fp_status) } } /* Underflow? */ - if (int128_getlo(a.mant) & (1ULL << DF_MANTBITS)) { + ret = int128_getlo(a.mant); + if (ret & (1ULL << DF_MANTBITS)) { /* Leading one means: No, we're normal. So, we should be done... */ - Double ret; - ret.i = 0; - ret.sign = a.sign; - ret.exp = a.exp; - ret.mant = int128_getlo(a.mant); - return ret.i; + ret = deposit64(ret, 52, 11, a.exp); + } else { + assert(a.exp == 1); + ret = deposit64(ret, 52, 11, 0); } - assert(a.exp == 1); - Double ret; - ret.i = 0; - ret.sign = a.sign; - ret.exp = 0; - ret.mant = int128_getlo(a.mant); - return ret.i; + ret = deposit64(ret, 63, 1, a.sign); + return ret; } float64 internal_mpyhh(float64 a, float64 b, From patchwork Tue Dec 24 20:05:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E11BBE7718E for ; Tue, 24 Dec 2024 20:18:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBDs-0000fH-0g; Tue, 24 Dec 2024 15:09:44 -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 1tQBDh-0007cC-JG for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:34 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDf-00030x-Ro for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:33 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21631789fcdso47001165ad.1 for ; Tue, 24 Dec 2024 12:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070970; x=1735675770; 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=F3y+AMSb8rvB6VTUgl6UjDCiMyf5UHg9L6oBAf1WE4w=; b=QRF+WSytAizZEVmDGUAhMK9zkDw4TEbThe4XS++5AIS9IWhEaINDFsii7hflDkHdgy ifb+AszHk8hQUcLJnrc5D6azXz4vuq3KsPDvXJXCK4d85/TxE10xiMnPQHqAWfj2kLv1 hiUvxBloaQofBvVACArluwBRsLzLEXwL1vvWoq9m1IyAfIiwsWplWM04TvOzFvAH5v/B E8AyZUT9EpdcW1EWha6tzDVClB1C3oGSf9eQqbXBFJL3y7TYjm4g+VwDb+qoL3Wf8/UA 9UCIPQ2NNNp7luSMD/Pku3pbyrn6S0peORnnhcFoOEND/468nj0dd2kkVYg/w+yVPOFz WLLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070970; x=1735675770; 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=F3y+AMSb8rvB6VTUgl6UjDCiMyf5UHg9L6oBAf1WE4w=; b=g/6Z5GuR44NQ0zgL6XVz0R9GHrXFAGH9nwLF1Vk7UOWXxAcqdBdFkz+nHlSY0SKoLE 5IYocgaGuNNeS8ewPkbh9X4BMSRpQR2GoX9Hja2TdlDoRXKxu3BS3wOXqeKwvWn9g/sK TP67NvOoUws2TTwihPigLhunefzBbbV0S5a5K8D/qyxdVo/8iAh6ArKf4l2gX+UxZW2S sSlTtFvm6o4hI1jNi0jU3pwQ8XUk9sSjOfkP0shXuI+FqCIsh3Mh627HlvstD/M/F6pt g0AIgINhwfu4nd8X2jYItXFvGN1WXcOq6ddIXVYKHEC5fum9o94y7zyr0LehaLm5rari TrUg== X-Gm-Message-State: AOJu0Yygs2Hk6fhxqhbTy6LXZeNwzmL8RNZ1SAo7jmDdPLXKTMk2WTw2 9JJ06PdJWZYphjssEqg23XuXBjNTg5VmGKsSFCSPsMT4++YSHP2WbQ36NxkwDMkdyZ24uVmjiDQ 1WQc= X-Gm-Gg: ASbGncsIP+2VIXn36HZBqtfctf1YeehRzzRUnwpg5FZcgFdjaHB6seJ3MgkKQggjAQi MdFakmMPNqU9uiIw5HeE9Vs4rsY8NHNU8XB0dG5gNfLtcSYB5j7OASmuMl60hNqVBFQyehsYQ9F smoS37cjd9Z3nh/TFcCjm6B0yfm6EbSQymTvYgCtF6dpdlHdXI9nKMzSTPTDorW2VB+Kxy0XOBa ViuGi20OCFM3Y8yNpoJpRJjRI7QYXKwGrPSgcso0t8SBdAao/DWMk3FRQbGwfATpuJuRX8k+MQ6 tPeQ6KXpsiwnp/LbS/n9Tt0bmQ== X-Google-Smtp-Source: AGHT+IGp7TOBZiUa7Up2TEXqhP5jtgaI4NWFdsR7EhUpgPxHA7kehlLUBYw+PxPoppz2x7GONPIZNQ== X-Received: by 2002:a05:6a00:66cb:b0:725:41c4:dbc7 with SMTP id d2e1a72fcca58-72abdae93e4mr26701042b3a.4.1735070970632; Tue, 24 Dec 2024 12:09:30 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 70/72] target/hexagon: Use mulu64 for int128_mul_6464 Date: Tue, 24 Dec 2024 12:05:19 -0800 Message-ID: <20241224200521.310066-71-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org No need to open-code 64x64->128-bit multiplication. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.c | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index ddc793fe14..07d2880776 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -82,38 +82,12 @@ int32_t float32_getexp(float32 f32) return -1; } -static uint32_t int128_getw0(Int128 x) -{ - return int128_getlo(x); -} - -static uint32_t int128_getw1(Int128 x) -{ - return int128_getlo(x) >> 32; -} - static Int128 int128_mul_6464(uint64_t ai, uint64_t bi) { - Int128 a, b; - uint64_t pp0, pp1a, pp1b, pp1s, pp2; + uint64_t l, h; - a = int128_make64(ai); - b = int128_make64(bi); - pp0 = (uint64_t)int128_getw0(a) * (uint64_t)int128_getw0(b); - pp1a = (uint64_t)int128_getw1(a) * (uint64_t)int128_getw0(b); - pp1b = (uint64_t)int128_getw1(b) * (uint64_t)int128_getw0(a); - pp2 = (uint64_t)int128_getw1(a) * (uint64_t)int128_getw1(b); - - pp1s = pp1a + pp1b; - if ((pp1s < pp1a) || (pp1s < pp1b)) { - pp2 += (1ULL << 32); - } - uint64_t ret_low = pp0 + (pp1s << 32); - if ((ret_low < pp0) || (ret_low < (pp1s << 32))) { - pp2 += 1; - } - - return int128_make128(ret_low, pp2 + (pp1s >> 32)); + mulu64(&l, &h, ai, bi); + return int128_make128(l, h); } static Int128 int128_sub_borrow(Int128 a, Int128 b, int borrow) From patchwork Tue Dec 24 20:05: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: 13920504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E8E3E7718D for ; Tue, 24 Dec 2024 20:11:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBEU-0004Ux-0w; Tue, 24 Dec 2024 15:10: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 1tQBDi-0007hJ-J8 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:34 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDh-00031C-1E for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:34 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2162c0f6a39so64893235ad.0 for ; Tue, 24 Dec 2024 12:09:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070972; x=1735675772; 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=gqH8fYhzwspoKRTd/2StonIkPkTT7XOo4RkleZm+9sc=; b=kVQpUWLD97v8QJGh8/M1Fp5P1mO3ne91LHuWaru6Xwpiep3Cjnd67WrieFH32PEGdx Jp0b5HA8D+dwllI99Zqw/dNDeOcl7o7H479WBkwqAHjTUoJBFDme9HS4jQPLedtvPSQ9 8VPiBc5ZYz/ql4Cccb+pnbi7xtXvj14cvCa8A51SjeCjLof+MpyhlgE3JyB8PTrTTm/J AbamsRl2R8QJl5dOLoI6q+eORKpb7eNK3+boGGicqEJNUjqo4qVyRuX3DLkPmUX9VLI4 zhqvSjgRdGFzidzMUjMg67MLbUJbvK/Zo9e4B6XpNoJCk9p7S1P+Qus7CXllQApj5t/X uiLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070972; x=1735675772; 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=gqH8fYhzwspoKRTd/2StonIkPkTT7XOo4RkleZm+9sc=; b=gGn8DdWpbBTKL+O579BQ7pzptMzD3O2N+T4y75vzIeuE0WBt9vMY40j4JCaGbKTj6B INseUsUzVkPpnYfpTKkP1i0Q55nY2rCq8qZPWjaYIt+KcBpr++OBjna0MkgMi9QjZE9y 8bjtl1UZMyp0WyyOu87HXzyiNmfo3Y7+RknjhN1nabYTafTsk2X/M5mvAFGICgKBlh0w MYxTTqm7lT0JOjL16CnxpJbt30KpV2mWh8WvOExBpNqVQQ6kLKle3diQ78Ht4T3JLmta DMDPP3tGd8Wl5k3zPC7VO29N0F+F/uqY9z3VrwQruLFRQ1BZj1k9eqHInURSOyQpLpKz HRnw== X-Gm-Message-State: AOJu0YxV3ddDYnpijZVyj0eAXkwLhDFPe6tDEFqUOwEZwliysHbqCT0c y04eNtlzttiZ/ddoJwjL0hx3noCclQ6ASKK0hQHd4b4ls0YLTa6tUzYP5o5YvkJG6HAV53CVFon ymK0= X-Gm-Gg: ASbGncvnu2ub1Wg7jDgx70w31yc5VGJse9EYo4QWnumkuwkymLlPhq/WSuC8tR579ZM /LBc5fMSAm+gLxbeLZyRJr1fc56Zx8uCH11VEI00usj9jZE2WcQ74vP+yhSjLEWhg2ROL8Eyq25 4L/aTXPFPxFOi9VOzcALw+lNvnYwSs1GUCQbpEjXMRyghglHSdyt/tiFArhCJc9LsG9S/gwHPv7 MAznHifrn2r8iyb4yYgRo94mzUemXs6barx3jgPrtPYwIlq6jvzvaoEPm5LHIdYhPdmR/JBHFRg /k2b6nDTDzucdhqAwgLrqAqBjA== X-Google-Smtp-Source: AGHT+IEkhpbpdS6F6/H/Dk6m19VBJ62D+mKY1kOpUGgjIygAH3PNJO/cS4QPgNhjXKnw72o9OAxX5w== X-Received: by 2002:a05:6a20:a122:b0:1e1:b220:63db with SMTP id adf61e73a8af0-1e5e1f56b34mr29072796637.16.1735070971709; Tue, 24 Dec 2024 12:09:31 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brian Cain Subject: [PULL 71/72] target/hexagon: Simplify internal_mpyhh setup Date: Tue, 24 Dec 2024 12:05:20 -0800 Message-ID: <20241224200521.310066-72-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Initialize x with accumulated via direct assignment, rather than multiplying by 1. Reviewed-by: Brian Cain Signed-off-by: Richard Henderson --- target/hexagon/fma_emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/hexagon/fma_emu.c b/target/hexagon/fma_emu.c index 07d2880776..c557141f11 100644 --- a/target/hexagon/fma_emu.c +++ b/target/hexagon/fma_emu.c @@ -455,7 +455,7 @@ float64 internal_mpyhh(float64 a, float64 b, float64_is_infinity(b)) { return float64_mul(a, b, fp_status); } - x.mant = int128_mul_6464(accumulated, 1); + x.mant = int128_make64(accumulated); x.sticky = sticky; prod = fGETUWORD(1, float64_getmant(a)) * fGETUWORD(1, float64_getmant(b)); x.mant = int128_add(x.mant, int128_mul_6464(prod, 0x100000000ULL)); From patchwork Tue Dec 24 20:05:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13920508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E658E7718F for ; Tue, 24 Dec 2024 20:11:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQBE6-0002Vx-Ip; Tue, 24 Dec 2024 15:09:58 -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 1tQBDm-0000Df-G8 for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:38 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDi-00031X-IL for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:38 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-21628b3fe7dso53770415ad.3 for ; Tue, 24 Dec 2024 12:09:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070973; x=1735675773; 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=jQjeFmlwXi1lZLuV5C0dso81HNv2ocXCvP6mdxjNCCQ=; b=xKElD0MArl+oIbQFDe/mPSA6zVyDJ2lE5cZBxqg21hY7Sr5DwD6RAT48vyXO+y6YTe u81dqP5nK/qMAgfopmvvgVeFqRQGJEIUsZDK3B8bXazYYbldCFiJ+7EcRBvACDoxUM3Q yOe0iycTJdrpnrlB98tp11cC84zH8nlDugLXyFatKtNq8UxDylmOdF6GBJJCW8yH6JHM Q6qG+16VWjyrAsGYxBSeA2gHM/kQVe42rsXhiioS2BAr8T4WbuA/jsqts3l4XmcwuadL goF1OTg0AB7XckvRkoO5p/dDa4xHroTQdC7M9inLW6cUMKRNyGmkXfh5q4WUJKNs2lHL KSKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070973; x=1735675773; 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=jQjeFmlwXi1lZLuV5C0dso81HNv2ocXCvP6mdxjNCCQ=; b=iyzI/27iZ3QfxFC48/sAl8ceyf6R2mjpKr9Uds/0ZqYh9yZ07t/wg0N+WZV7LssQ+9 i1cNFhQaXPMs7qwdCxlR71NaafJ6O6/9nUMukg6F87LqDTgUrTrns+BIHy+h1HpDNt16 INPay3t2LA0y/9nam3AaVrm5QxY2kduVHpnK4T5i2FkFR1PvVIUHup+vFyCDTkNmlvcx nycXRTbwQcwOCm974zjh7f7IPUC7MlYCgcRPMwVu2o4HvRDN+URnqRfrO3QPeE50jTDN EZCWexUWbyk0xm4qT4ct18pyo3aDqrojNMWescrHLWAmdpBlMyY9p7C786hDrPMR6lKA +tQA== X-Gm-Message-State: AOJu0YyXhwNnf9rLwEraqZ1Nf2obXZqScKgppEXTJpQIpXE4qDYyVYpA eJ7XMD5bj4yxU5xzn1N4ki2HFqrUrxTEeFBr5tG7sAlzsGWwKUJ2geNpCDcQMe7UMZCq2MIor9t pl1M= X-Gm-Gg: ASbGncs55qzkVXUZVz2P9ToMLipNPX+QiquGgwvK6g1oZa7pWEYjT2GS9RWAkVqW/xQ j+W/dGBdRZaNRsSeCFGmIHnltDm2KgDYE2P/HPoj0S6HBuo3HLUlBk3wHRkQK9OfCECaIogV9Ez v4URHeJ08bCu2poBzQybimaTYXYRnJnOlOyGqA+WffrcHFLTFdpTp9JupDC7Zr9HObJ7cmQSC2i GSjio71T+uVOyPfIH6jV0uhvKzuj22U0GR8LHZpMPEicE4BQTEwpTfMMaod0kdna+tzL4NdhmHF jqgZaaMiwnZN1nqYuKB60JmLUw== X-Google-Smtp-Source: AGHT+IFkUNnQ3C5JVyAPUPcmeh/cd26qbyaXvHD2Fk07wyNgZpdFBF5brmRcBmM9cUntU6zsEKeHCA== X-Received: by 2002:a05:6a21:100f:b0:1e0:d848:9e83 with SMTP id adf61e73a8af0-1e5e07a853amr28932876637.25.1735070973033; Tue, 24 Dec 2024 12:09:33 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 72/72] accel/tcg: Move gen_intermediate_code to TCGCPUOps.translate_core Date: Tue, 24 Dec 2024 12:05:21 -0800 Message-ID: <20241224200521.310066-73-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Convert all targets simultaneously, as the gen_intermediate_code function disappears from the target. While there are possible workarounds, they're larger than simply performing the conversion. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/exec/translator.h | 14 -------------- include/hw/core/tcg-cpu-ops.h | 13 +++++++++++++ target/alpha/cpu.h | 2 ++ target/arm/internals.h | 2 ++ target/avr/cpu.h | 2 ++ target/hexagon/cpu.h | 2 ++ target/hppa/cpu.h | 2 ++ target/i386/tcg/helper-tcg.h | 2 ++ target/loongarch/internals.h | 2 ++ target/m68k/cpu.h | 2 ++ target/microblaze/cpu.h | 2 ++ target/mips/tcg/tcg-internal.h | 2 ++ target/openrisc/cpu.h | 2 ++ target/ppc/cpu.h | 2 ++ target/riscv/cpu.h | 3 +++ target/rx/cpu.h | 2 ++ target/s390x/s390x-internal.h | 2 ++ target/sh4/cpu.h | 2 ++ target/sparc/cpu.h | 2 ++ target/tricore/cpu.h | 2 ++ target/xtensa/cpu.h | 2 ++ accel/tcg/cpu-exec.c | 8 +++++--- accel/tcg/translate-all.c | 8 +++++--- target/alpha/cpu.c | 1 + target/alpha/translate.c | 4 ++-- target/arm/cpu.c | 1 + target/arm/tcg/cpu-v7m.c | 1 + target/arm/tcg/translate.c | 5 ++--- target/avr/cpu.c | 1 + target/avr/translate.c | 6 +++--- target/hexagon/cpu.c | 1 + target/hexagon/translate.c | 4 ++-- target/hppa/cpu.c | 1 + target/hppa/translate.c | 4 ++-- target/i386/tcg/tcg-cpu.c | 1 + target/i386/tcg/translate.c | 5 ++--- target/loongarch/cpu.c | 1 + target/loongarch/tcg/translate.c | 4 ++-- target/m68k/cpu.c | 1 + target/m68k/translate.c | 4 ++-- target/microblaze/cpu.c | 1 + target/microblaze/translate.c | 4 ++-- target/mips/cpu.c | 1 + target/mips/tcg/translate.c | 4 ++-- target/openrisc/cpu.c | 1 + target/openrisc/translate.c | 4 ++-- target/ppc/cpu_init.c | 1 + target/ppc/translate.c | 4 ++-- target/riscv/tcg/tcg-cpu.c | 1 + target/riscv/translate.c | 4 ++-- target/rx/cpu.c | 1 + target/rx/translate.c | 4 ++-- target/s390x/cpu.c | 1 + target/s390x/tcg/translate.c | 4 ++-- target/sh4/cpu.c | 1 + target/sh4/translate.c | 4 ++-- target/sparc/cpu.c | 1 + target/sparc/translate.c | 4 ++-- target/tricore/cpu.c | 1 + target/tricore/translate.c | 5 ++--- target/xtensa/cpu.c | 1 + target/xtensa/translate.c | 4 ++-- 62 files changed, 121 insertions(+), 62 deletions(-) diff --git a/include/exec/translator.h b/include/exec/translator.h index 41e2a41180..d70942a10f 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -21,20 +21,6 @@ #include "qemu/bswap.h" #include "exec/vaddr.h" -/** - * gen_intermediate_code - * @cpu: cpu context - * @tb: translation block - * @max_insns: max number of instructions to translate - * @pc: guest virtual program counter address - * @host_pc: host physical program counter address - * - * This function must be provided by the target, which should create - * the target-specific DisasContext, and then invoke translator_loop. - */ -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc); - /** * DisasJumpType: * @DISAS_NEXT: Next instruction in program order. diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 663efb9133..2e3f1690f1 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -24,6 +24,19 @@ struct TCGCPUOps { * Called when the first CPU is realized. */ void (*initialize)(void); + /** + * @translate_code: Translate guest instructions to TCGOps + * @cpu: cpu context + * @tb: translation block + * @max_insns: max number of instructions to translate + * @pc: guest virtual program counter address + * @host_pc: host physical program counter address + * + * This function must be provided by the target, which should create + * the target-specific DisasContext, and then invoke translator_loop. + */ + void (*translate_code)(CPUState *cpu, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); /** * @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock * diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 3556d3227f..80562adfb5 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -431,6 +431,8 @@ enum { }; void alpha_translate_init(void); +void alpha_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); #define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU diff --git a/target/arm/internals.h b/target/arm/internals.h index c3a5b1385f..863a84edf8 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -357,6 +357,8 @@ void init_cpreg_list(ARMCPU *cpu); void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); void arm_translate_init(void); +void arm_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); void arm_cpu_register_gdb_commands(ARMCPU *cpu); void aarch64_cpu_register_gdb_commands(ARMCPU *cpu, GString *, diff --git a/target/avr/cpu.h b/target/avr/cpu.h index 4725535102..06f5ae4d1b 100644 --- a/target/avr/cpu.h +++ b/target/avr/cpu.h @@ -183,6 +183,8 @@ static inline void set_avr_feature(CPUAVRState *env, int feature) } void avr_cpu_tcg_init(void); +void avr_cpu_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); int cpu_avr_exec(CPUState *cpu); diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h index 14e6e819c2..79e60d4bfa 100644 --- a/target/hexagon/cpu.h +++ b/target/hexagon/cpu.h @@ -150,6 +150,8 @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, vaddr *pc, typedef HexagonCPU ArchCPU; void hexagon_translate_init(void); +void hexagon_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); #include "exec/cpu-all.h" diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index e45ba50a59..22a6510e08 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -303,6 +303,8 @@ static inline int HPPA_BTLB_ENTRIES(CPUHPPAState *env) } void hppa_translate_init(void); +void hppa_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h index 696d6ef016..54d845379c 100644 --- a/target/i386/tcg/helper-tcg.h +++ b/target/i386/tcg/helper-tcg.h @@ -59,6 +59,8 @@ static inline target_long lshift(target_long x, int n) /* translate.c */ void tcg_x86_init(void); +void x86_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); /* excp_helper.c */ G_NORETURN void raise_exception(CPUX86State *env, int exception_index); diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index 0655ac948b..ad9cf4fc7a 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -17,6 +17,8 @@ #define TARGET_VIRT_MASK MAKE_64BIT_MASK(0, TARGET_VIRT_ADDR_SPACE_BITS) void loongarch_translate_init(void); +void loongarch_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); void G_NORETURN do_raise_exception(CPULoongArchState *env, uint32_t exception, diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index b5bbeedb7a..ddb0f29f4a 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -193,6 +193,8 @@ int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void m68k_tcg_init(void); +void m68k_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); void m68k_cpu_init_gdb(M68kCPU *cpu); uint32_t cpu_m68k_get_ccr(CPUM68KState *env); void cpu_m68k_set_ccr(CPUM68KState *env, uint32_t); diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 3e5a3e5c60..f6879eee35 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -398,6 +398,8 @@ static inline void mb_cpu_write_msr(CPUMBState *env, uint32_t val) } void mb_tcg_init(void); +void mb_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); #define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h index aef032c48d..74fc1309a7 100644 --- a/target/mips/tcg/tcg-internal.h +++ b/target/mips/tcg/tcg-internal.h @@ -16,6 +16,8 @@ #include "cpu.h" void mips_tcg_init(void); +void mips_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); G_NORETURN void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index c9fe9ae12d..b97d2ffdd2 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -301,6 +301,8 @@ void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void openrisc_translate_init(void); +void openrisc_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); int print_insn_or1k(bfd_vma addr, disassemble_info *info); #ifndef CONFIG_USER_ONLY diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 2ffac2ed03..0b8b4c0517 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1581,6 +1581,8 @@ extern const VMStateDescription vmstate_ppc_cpu; /*****************************************************************************/ void ppc_translate_init(void); +void ppc_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); #if !defined(CONFIG_USER_ONLY) void ppc_store_sdr1(CPUPPCState *env, target_ulong value); diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 284b112821..252fdb8672 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -602,6 +602,9 @@ RISCVException smstateen_acc_ok(CPURISCVState *env, int index, uint64_t bit); void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv, bool virt_en); void riscv_translate_init(void); +void riscv_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); + G_NORETURN void riscv_raise_exception(CPURISCVState *env, uint32_t exception, uintptr_t pc); diff --git a/target/rx/cpu.h b/target/rx/cpu.h index c53593d7aa..5ba1874bd7 100644 --- a/target/rx/cpu.h +++ b/target/rx/cpu.h @@ -139,6 +139,8 @@ int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void rx_translate_init(void); +void rx_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte); #include "exec/cpu-all.h" diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h index 4cc435042c..a750e7a343 100644 --- a/target/s390x/s390x-internal.h +++ b/target/s390x/s390x-internal.h @@ -399,6 +399,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, /* translate.c */ void s390x_translate_init(void); +void s390x_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); void s390x_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data); diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index d928bcf006..d536d5d715 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -248,6 +248,8 @@ G_NORETURN void superh_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, uintptr_t retaddr); void sh4_translate_init(void); +void sh4_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); #if !defined(CONFIG_USER_ONLY) hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 5c981234bb..dda811503b 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -609,6 +609,8 @@ int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr, /* translate.c */ void sparc_tcg_init(void); +void sparc_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); /* fop_helper.c */ target_ulong cpu_get_fsr(CPUSPARCState *); diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 220af69fc2..8e431d7922 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -252,6 +252,8 @@ FIELD(TB_FLAGS, PRIV, 0, 2) void cpu_state_reset(CPUTriCoreState *s); void tricore_tcg_init(void); +void tricore_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, vaddr *pc, uint64_t *cs_base, uint32_t *flags) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 77e48eef19..0e6302c5bd 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -617,6 +617,8 @@ G_NORETURN void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, void xtensa_collect_sr_names(const XtensaConfig *config); void xtensa_translate_init(void); +void xtensa_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc); void **xtensa_get_regfile_by_name(const char *name, int entries, int bits); void xtensa_breakpoint_handler(CPUState *cs); void xtensa_register_core(XtensaConfigList *node); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index b507049ddb..d48b82a932 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -1088,11 +1088,13 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp) if (!tcg_target_initialized) { /* Check mandatory TCGCPUOps handlers */ + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; #ifndef CONFIG_USER_ONLY - assert(cpu->cc->tcg_ops->cpu_exec_halt); - assert(cpu->cc->tcg_ops->cpu_exec_interrupt); + assert(tcg_ops->cpu_exec_halt); + assert(tcg_ops->cpu_exec_interrupt); #endif /* !CONFIG_USER_ONLY */ - cpu->cc->tcg_ops->initialize(); + assert(tcg_ops->translate_code); + tcg_ops->initialize(); tcg_target_initialized = true; } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 572a8a8797..453eb20ec9 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -276,8 +276,10 @@ static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb, tcg_func_start(tcg_ctx); - tcg_ctx->cpu = env_cpu(env); - gen_intermediate_code(env_cpu(env), tb, max_insns, pc, host_pc); + CPUState *cs = env_cpu(env); + tcg_ctx->cpu = cs; + cs->cc->tcg_ops->translate_code(cs, tb, max_insns, pc, host_pc); + assert(tb->size != 0); tcg_ctx->cpu = NULL; *max_insns = tb->icount; @@ -364,7 +366,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, /* * Overflow of code_gen_buffer, or the current slice of it. * - * TODO: We don't need to re-do gen_intermediate_code, nor + * TODO: We don't need to re-do tcg_ops->translate_code, nor * should we re-do the tcg optimization currently hidden * inside tcg_gen_code. All that should be required is to * flush the TBs, allocate a new TB, re-initialize it per diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 9fa506bff9..e1b898e575 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -224,6 +224,7 @@ static const struct SysemuCPUOps alpha_sysemu_ops = { static const TCGCPUOps alpha_tcg_ops = { .initialize = alpha_translate_init, + .translate_code = alpha_translate_code, .synchronize_from_tb = alpha_cpu_synchronize_from_tb, .restore_state_to_opc = alpha_restore_state_to_opc, diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 629ff3cde9..2156c02214 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -2955,8 +2955,8 @@ static const TranslatorOps alpha_tr_ops = { .tb_stop = alpha_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void alpha_translate_code(CPUState *cpu, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc; translator_loop(cpu, tb, max_insns, pc, host_pc, &alpha_tr_ops, &dc.base); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 019183c9ea..dcedadc89e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2682,6 +2682,7 @@ static const struct SysemuCPUOps arm_sysemu_ops = { #ifdef CONFIG_TCG static const TCGCPUOps arm_tcg_ops = { .initialize = arm_translate_init, + .translate_code = arm_translate_code, .synchronize_from_tb = arm_cpu_synchronize_from_tb, .debug_excp_handler = arm_debug_excp_handler, .restore_state_to_opc = arm_restore_state_to_opc, diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c index 58e54578d6..03acdf83e0 100644 --- a/target/arm/tcg/cpu-v7m.c +++ b/target/arm/tcg/cpu-v7m.c @@ -234,6 +234,7 @@ static void cortex_m55_initfn(Object *obj) static const TCGCPUOps arm_v7m_tcg_ops = { .initialize = arm_translate_init, + .translate_code = arm_translate_code, .synchronize_from_tb = arm_cpu_synchronize_from_tb, .debug_excp_handler = arm_debug_excp_handler, .restore_state_to_opc = arm_restore_state_to_opc, diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 9ee761fc64..c16b59ab88 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -8093,9 +8093,8 @@ static const TranslatorOps thumb_translator_ops = { .tb_stop = arm_tr_tb_stop, }; -/* generate intermediate code for basic block 'tb'. */ -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void arm_translate_code(CPUState *cpu, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc = { }; const TranslatorOps *ops = &arm_translator_ops; diff --git a/target/avr/cpu.c b/target/avr/cpu.c index 2dccb09c5e..8a126ff322 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -207,6 +207,7 @@ static const struct SysemuCPUOps avr_sysemu_ops = { static const TCGCPUOps avr_tcg_ops = { .initialize = avr_cpu_tcg_init, + .translate_code = avr_cpu_translate_code, .synchronize_from_tb = avr_cpu_synchronize_from_tb, .restore_state_to_opc = avr_restore_state_to_opc, .cpu_exec_interrupt = avr_cpu_exec_interrupt, diff --git a/target/avr/translate.c b/target/avr/translate.c index f13b997f8d..4ab71d8138 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -2599,7 +2599,7 @@ static bool trans_WDR(DisasContext *ctx, arg_WDR *a) * * - translate() * - canonicalize_skip() - * - gen_intermediate_code() + * - translate_code() * - restore_state_to_opc() * */ @@ -2795,8 +2795,8 @@ static const TranslatorOps avr_tr_ops = { .tb_stop = avr_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void avr_cpu_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc = { }; translator_loop(cs, tb, max_insns, pc, host_pc, &avr_tr_ops, &dc.base); diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index c9817c7192..0b7fc98f6c 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -325,6 +325,7 @@ static void hexagon_cpu_init(Object *obj) static const TCGCPUOps hexagon_tcg_ops = { .initialize = hexagon_translate_init, + .translate_code = hexagon_translate_code, .synchronize_from_tb = hexagon_cpu_synchronize_from_tb, .restore_state_to_opc = hexagon_restore_state_to_opc, }; diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 562105705a..fe7858703c 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -1026,8 +1026,8 @@ static const TranslatorOps hexagon_tr_ops = { .tb_stop = hexagon_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void hexagon_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index c9062e60b6..47d0160955 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -223,6 +223,7 @@ static const struct SysemuCPUOps hppa_sysemu_ops = { static const TCGCPUOps hppa_tcg_ops = { .initialize = hppa_translate_init, + .translate_code = hppa_translate_code, .synchronize_from_tb = hppa_cpu_synchronize_from_tb, .restore_state_to_opc = hppa_restore_state_to_opc, diff --git a/target/hppa/translate.c b/target/hppa/translate.c index d13f80fe3e..dc04f9f3c0 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4869,8 +4869,8 @@ static const TranslatorOps hppa_tr_ops = { #endif }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void hppa_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx = { }; translator_loop(cs, tb, max_insns, pc, host_pc, &hppa_tr_ops, &ctx.base); diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 231ecac37d..14ee038079 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -109,6 +109,7 @@ static bool x86_debug_check_breakpoint(CPUState *cs) static const TCGCPUOps x86_tcg_ops = { .initialize = tcg_x86_init, + .translate_code = x86_translate_code, .synchronize_from_tb = x86_cpu_synchronize_from_tb, .restore_state_to_opc = x86_restore_state_to_opc, .cpu_exec_enter = x86_cpu_exec_enter, diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 903553dc88..834aea1e59 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -3814,9 +3814,8 @@ static const TranslatorOps i386_tr_ops = { .tb_stop = i386_tr_tb_stop, }; -/* generate intermediate code for basic block 'tb'. */ -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void x86_translate_code(CPUState *cpu, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc; diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index f5bc8720d1..58415ffe99 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -795,6 +795,7 @@ static void loongarch_cpu_dump_state(CPUState *cs, FILE *f, int flags) static const TCGCPUOps loongarch_tcg_ops = { .initialize = loongarch_translate_init, + .translate_code = loongarch_translate_code, .synchronize_from_tb = loongarch_cpu_synchronize_from_tb, .restore_state_to_opc = loongarch_restore_state_to_opc, diff --git a/target/loongarch/tcg/translate.c b/target/loongarch/tcg/translate.c index 1fca4afc73..68be999410 100644 --- a/target/loongarch/tcg/translate.c +++ b/target/loongarch/tcg/translate.c @@ -333,8 +333,8 @@ static const TranslatorOps loongarch_tr_ops = { .tb_stop = loongarch_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void loongarch_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 9de8ce6707..41dfdf5804 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -551,6 +551,7 @@ static const struct SysemuCPUOps m68k_sysemu_ops = { static const TCGCPUOps m68k_tcg_ops = { .initialize = m68k_tcg_init, + .translate_code = m68k_translate_code, .restore_state_to_opc = m68k_restore_state_to_opc, #ifndef CONFIG_USER_ONLY diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 077151c62d..dec2967fce 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6118,8 +6118,8 @@ static const TranslatorOps m68k_tr_ops = { .tb_stop = m68k_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void m68k_translate_code(CPUState *cpu, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc; translator_loop(cpu, tb, max_insns, pc, host_pc, &m68k_tr_ops, &dc.base); diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index eba819378d..f114789abd 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -423,6 +423,7 @@ static const struct SysemuCPUOps mb_sysemu_ops = { static const TCGCPUOps mb_tcg_ops = { .initialize = mb_tcg_init, + .translate_code = mb_translate_code, .synchronize_from_tb = mb_cpu_synchronize_from_tb, .restore_state_to_opc = mb_restore_state_to_opc, diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index d53995c26d..24005f05b2 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1779,8 +1779,8 @@ static const TranslatorOps mb_tr_ops = { .tb_stop = mb_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void mb_translate_code(CPUState *cpu, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc; translator_loop(cpu, tb, max_insns, pc, host_pc, &mb_tr_ops, &dc.base); diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 1b0cf6df9c..e3af02a4e6 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -547,6 +547,7 @@ static const Property mips_cpu_properties[] = { #include "hw/core/tcg-cpu-ops.h" static const TCGCPUOps mips_tcg_ops = { .initialize = mips_tcg_init, + .translate_code = mips_translate_code, .synchronize_from_tb = mips_cpu_synchronize_from_tb, .restore_state_to_opc = mips_restore_state_to_opc, diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index bd1ef4e1fc..78b848a6d9 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -15231,8 +15231,8 @@ static const TranslatorOps mips_tr_ops = { .tb_stop = mips_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void mips_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 7913a0c3e1..b7bab0d7ab 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -236,6 +236,7 @@ static const struct SysemuCPUOps openrisc_sysemu_ops = { static const TCGCPUOps openrisc_tcg_ops = { .initialize = openrisc_translate_init, + .translate_code = openrisc_translate_code, .synchronize_from_tb = openrisc_cpu_synchronize_from_tb, .restore_state_to_opc = openrisc_restore_state_to_opc, diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 028ba66631..7a6af183ae 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1646,8 +1646,8 @@ static const TranslatorOps openrisc_tr_ops = { .tb_stop = openrisc_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void openrisc_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 0fcef630f1..c05c2dc42d 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -7431,6 +7431,7 @@ static const struct SysemuCPUOps ppc_sysemu_ops = { static const TCGCPUOps ppc_tcg_ops = { .initialize = ppc_translate_init, + .translate_code = ppc_translate_code, .restore_state_to_opc = ppc_restore_state_to_opc, #ifdef CONFIG_USER_ONLY diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 8ab87f42d6..80638ab535 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -6669,8 +6669,8 @@ static const TranslatorOps ppc_tr_ops = { .tb_stop = ppc_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void ppc_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index f0129811fd..8b89c99c0f 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -135,6 +135,7 @@ static void riscv_restore_state_to_opc(CPUState *cs, static const TCGCPUOps riscv_tcg_ops = { .initialize = riscv_translate_init, + .translate_code = riscv_translate_code, .synchronize_from_tb = riscv_cpu_synchronize_from_tb, .restore_state_to_opc = riscv_restore_state_to_opc, diff --git a/target/riscv/translate.c b/target/riscv/translate.c index a76f67c5dd..a992d4f3c6 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1346,8 +1346,8 @@ static const TranslatorOps riscv_tr_ops = { .tb_stop = riscv_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void riscv_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 558280c794..8c50c7a1bc 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -196,6 +196,7 @@ static const struct SysemuCPUOps rx_sysemu_ops = { static const TCGCPUOps rx_tcg_ops = { .initialize = rx_translate_init, + .translate_code = rx_translate_code, .synchronize_from_tb = rx_cpu_synchronize_from_tb, .restore_state_to_opc = rx_restore_state_to_opc, .tlb_fill = rx_cpu_tlb_fill, diff --git a/target/rx/translate.c b/target/rx/translate.c index 4f43654bad..bbda703be8 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -2258,8 +2258,8 @@ static const TranslatorOps rx_tr_ops = { .tb_stop = rx_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void rx_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 0a6847b027..97d41c23de 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -362,6 +362,7 @@ void cpu_get_tb_cpu_state(CPUS390XState *env, vaddr *pc, static const TCGCPUOps s390_tcg_ops = { .initialize = s390x_translate_init, + .translate_code = s390x_translate_code, .restore_state_to_opc = s390x_restore_state_to_opc, #ifdef CONFIG_USER_ONLY diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 81554f2ad9..00073c5560 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -6481,8 +6481,8 @@ static const TranslatorOps s390x_tr_ops = { .disas_log = s390x_tr_disas_log, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void s390x_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index e9d3e12a62..24a22724c6 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -251,6 +251,7 @@ static const struct SysemuCPUOps sh4_sysemu_ops = { static const TCGCPUOps superh_tcg_ops = { .initialize = sh4_translate_init, + .translate_code = sh4_translate_code, .synchronize_from_tb = superh_cpu_synchronize_from_tb, .restore_state_to_opc = superh_restore_state_to_opc, diff --git a/target/sh4/translate.c b/target/sh4/translate.c index f076da9bac..bcdd558818 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2318,8 +2318,8 @@ static const TranslatorOps sh4_tr_ops = { .tb_stop = sh4_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void sh4_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 373a335c39..fbd38ec334 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -996,6 +996,7 @@ static const struct SysemuCPUOps sparc_sysemu_ops = { static const TCGCPUOps sparc_tcg_ops = { .initialize = sparc_tcg_init, + .translate_code = sparc_translate_code, .synchronize_from_tb = sparc_cpu_synchronize_from_tb, .restore_state_to_opc = sparc_restore_state_to_opc, diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 465e20f4f3..7e5c7351cb 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5819,8 +5819,8 @@ static const TranslatorOps sparc_tr_ops = { .tb_stop = sparc_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void sparc_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc = {}; diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 95fb546666..95202fadbf 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -172,6 +172,7 @@ static const struct SysemuCPUOps tricore_sysemu_ops = { static const TCGCPUOps tricore_tcg_ops = { .initialize = tricore_tcg_init, + .translate_code = tricore_translate_code, .synchronize_from_tb = tricore_cpu_synchronize_from_tb, .restore_state_to_opc = tricore_restore_state_to_opc, .tlb_fill = tricore_cpu_tlb_fill, diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 2b67395c09..0ef3743f3e 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8460,9 +8460,8 @@ static const TranslatorOps tricore_tr_ops = { .tb_stop = tricore_tr_tb_stop, }; - -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void tricore_translate_code(CPUState *cs, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext ctx; translator_loop(cs, tb, max_insns, pc, host_pc, diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 0d4d79b58b..0910a3d290 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -232,6 +232,7 @@ static const struct SysemuCPUOps xtensa_sysemu_ops = { static const TCGCPUOps xtensa_tcg_ops = { .initialize = xtensa_translate_init, + .translate_code = xtensa_translate_code, .debug_excp_handler = xtensa_breakpoint_handler, .restore_state_to_opc = xtensa_restore_state_to_opc, diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 3c62c99b4f..4f02cefde3 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1228,8 +1228,8 @@ static const TranslatorOps xtensa_translator_ops = { .tb_stop = xtensa_tr_tb_stop, }; -void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns, - vaddr pc, void *host_pc) +void xtensa_translate_code(CPUState *cpu, TranslationBlock *tb, + int *max_insns, vaddr pc, void *host_pc) { DisasContext dc = {}; translator_loop(cpu, tb, max_insns, pc, host_pc,