From patchwork Tue Jul 7 21:24:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 138687 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51C3F4BA2E28 for ; Tue, 7 Jul 2026 21:25:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51C3F4BA2E28 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=vrull.eu header.i=@vrull.eu header.a=rsa-sha256 header.s=google header.b=GEfWh9iU X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id BA3BA4BA543C for ; Tue, 7 Jul 2026 21:24:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA3BA4BA543C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA3BA4BA543C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783459491; cv=none; b=FYP7YWy7+GYJpyRRtlns8gpJZJjh+wRXgGkqqle0Zz8X+pSgOtWrrYGMXVZUThhJmweckyWkP/1WNDDNyOCqw2JBKjZv6BLbwEl65oeHesCaswBQnj4QUCVsUt2eB1vnkiiVDTAWZiqtrdoF2lmqwndn7QZoJN43Y4LUr5Y5a7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783459491; c=relaxed/simple; bh=wCWvJILBdT6eyReVxPvKO7kMHSxgC7f8Ba82Fic5drI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=o+QRQ4J8gCq1jZtex2g8sw0fGvLUKe9obvlO8Q1fqZOJJq/TeybnMmQmPFG/asCWWCjkkakq9/F3zQ1+/BpUf+yMDRvXxmmBHVQ/5lipVPXwve2ls+taBEbrwuKWB3T/FE9yGNSf/YHwZmWXE9gx1Ikn88PzT7/gApiUlmAUuok= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=vrull.eu header.i=@vrull.eu header.a=rsa-sha256 header.s=google header.b=GEfWh9iU DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA3BA4BA543C Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5aec090da14so465143e87.2 for ; Tue, 07 Jul 2026 14:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1783459489; x=1784064289; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ZXtzQ+kbRIblVE3tBgGgbUMSOLdg877OXoSXlJLruV0=; b=GEfWh9iU5H716eOA4m9MSo6iGx4oc5cu9h3t3Vh8bLYLuFjpeTeNu7gj1jH8zvx4h+ qiXQjXepz0dz5n9BCwz+BJhvNkZdzcLVa/M3gPsxS2xROVkQMVydBM7JkN3e5K1NuMOo D+3Qflfqetk1xuQQeMzKnRxdf9DZ2byyMaNSUm9jXeOh5Ep4e9HEkRwsXd0IL2sxG6JK HmHsx08ITZK9u6x9X+5o0RTqqguR+ELzRUKyCyz/cyNvWBY70/T8/8X4msEkrtKUn5GS V4OwOX/Kcd0+Ev5iY4cFUrHNcnGlUjrjdi0x8fBFIT9wxIRfA1C+jHp2pT5gQ/V7+P9w JGiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783459489; x=1784064289; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZXtzQ+kbRIblVE3tBgGgbUMSOLdg877OXoSXlJLruV0=; b=ANgv4+FIr493VHn30pApIyMOoroKz03AmaE6ATq0a5V+BI9R5xiEWnCTTeVIDs/zSG wRQBENdKZcRn6F3Ee3N/oZ63Wff7TL+ed/VBwmZGuSiOE9QokC8dooLc+yxu76zs7FnY DwGBYbrEYKfkNP2T+ZooQlz0gpI7F5Udilu7NxAgut5FCKjXFgXDclAlZXUgwDbqvpnF 7Pi8R7aF1uJBMzqWtwIzQkxFoFmVwoglop0NReQVXjpHkRQT1iPfvVTow128u5yNzWd3 tP+UIisJr4i/xEFigYkIZutirFVdyTTF+do9CVaqjb55/WDDBv2O3ibNK9Z+V3YlOgSZ bCIg== X-Gm-Message-State: AOJu0YzmBmboFJWb6m//Pp9oBpMJ25+jcvxAbYBxTRsg6iRszyryFEe8 CiOreGd/ZqRlZqpmFJ9qhjDjxbiPviU2uTB+JqpqKWzI2DE7Zxr4d8tCD1k+GONy+mNvHTtwnVJ U/s+hpDw= X-Gm-Gg: AfdE7cmCmyEPQXpuln6rzSLAP//zNFjL0vDTWYV3WsiUJXLe/e+SNTI9aPHn3bNghFm mQ4UzVCqyqoAZxzQCRtIyyCk4iHPUtSIEECYUdLqSkzdx3NQIdMqS+wg65D2uThaNcSfcijFBmD TVMferkqzbs5VLlK7YdvqZMZ9mucDsejI3Q2iZ3Kj9sUliM2S8QMyLUcPiLifTPJURo+ZJHyJBi rSuwqJFVFpdCm8gnp6RFSsdi8JVzjH29gM3l+KJ3A9LWGa9JKaNmLlImI/V0bM/wgTymABA3Dxv AlLKe44GnoiDTSIDJFEWocGEE2GUD21pcW4vIq7CERAb1JrEHybfdy1YZw6IVOhupeth4+JjmLi 1V6rSfDmkGOy2tbbJxqMpjPJ3QvTG8CpugmZL2AlVsioARzgGiPKECUCji0Ok5l9UXWDYbeZBrf EdN8DpV+kH3sGdsNPXZO2AopJa8IhfF3I= X-Received: by 2002:a05:6512:3b20:b0:5ae:bfab:19c3 with SMTP id 2adb3069b0e04-5aed4541422mr2093630e87.2.1783459489102; Tue, 07 Jul 2026 14:24:49 -0700 (PDT) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b00c763974sm464584e87.49.2026.07.07.14.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 14:24:48 -0700 (PDT) From: Philipp Tomsich To: gcc-patches@gcc.gnu.org Cc: Philipp Tomsich Subject: [PATCH v1] aarch64: populate issue_info for the ampere1 family Date: Tue, 7 Jul 2026 23:24:44 +0200 Message-Id: <20260707212444.1552536-1-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org The ampere1, ampere1a and ampere1b tunes leave the vector issue_info in cpu_vector_cost as NULL, so determine_suggested_unroll_factor bails out early and reduction loops are never multi-accumulator-unrolled on these cores. Fill it in from the ampere1 optimization guide (L1D two 128-bit loads plus one store per cycle, four general ops per cycle). gcc/ChangeLog: * config/aarch64/tuning_models/ampere1.h (ampere1_scalar_issue_info) (ampere1_advsimd_issue_info, ampere1_vec_issue_info): New. (ampere1_vector_cost): Use ampere1_vec_issue_info for issue_info. * config/aarch64/tuning_models/ampere1b.h (ampere1b_scalar_issue_info) (ampere1b_advsimd_issue_info, ampere1b_vec_issue_info): New. (ampere1b_vector_cost): Use ampere1b_vec_issue_info for issue_info. gcc/testsuite/ChangeLog: * gcc.target/aarch64/ampere1-reduction-unroll-1.c: New test. Signed-off-by: Philipp Tomsich --- gcc/config/aarch64/tuning_models/ampere1.h | 32 ++++++++++++++++++- gcc/config/aarch64/tuning_models/ampere1b.h | 32 ++++++++++++++++++- .../aarch64/ampere1-reduction-unroll-1.c | 20 ++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/ampere1-reduction-unroll-1.c diff --git a/gcc/config/aarch64/tuning_models/ampere1.h b/gcc/config/aarch64/tuning_models/ampere1.h index 53d45761b42f..e2a42f585dd9 100644 --- a/gcc/config/aarch64/tuning_models/ampere1.h +++ b/gcc/config/aarch64/tuning_models/ampere1.h @@ -46,6 +46,36 @@ static const advsimd_vec_cost ampere1_advsimd_vector_cost = 1 /* store_cost */ }; +static const aarch64_scalar_vec_issue_info ampere1_scalar_issue_info = +{ + 3, /* loads_stores_per_cycle */ + 1, /* stores_per_cycle */ + 4, /* general_ops_per_cycle */ + 0, /* fp_simd_load_general_ops */ + 1 /* fp_simd_store_general_ops */ +}; + +static const aarch64_advsimd_vec_issue_info ampere1_advsimd_issue_info = +{ + { + 2, /* loads_stores_per_cycle */ + 2, /* stores_per_cycle */ + 4, /* general_ops_per_cycle */ + 0, /* fp_simd_load_general_ops */ + 1 /* fp_simd_store_general_ops */ + }, + 2, /* ld2_st2_general_ops */ + 2, /* ld3_st3_general_ops */ + 3 /* ld4_st4_general_ops */ +}; + +static const aarch64_vec_issue_info ampere1_vec_issue_info = +{ + &ere1_scalar_issue_info, + &ere1_advsimd_issue_info, + nullptr /* sve */ +}; + /* Ampere-1 costs for vector insn classes. */ static const struct cpu_vector_cost ampere1_vector_cost = { @@ -57,7 +87,7 @@ static const struct cpu_vector_cost ampere1_vector_cost = 1, /* cond_not_taken_branch_cost */ &ere1_advsimd_vector_cost, /* advsimd */ nullptr, /* sve */ - nullptr /* issue_info */ + &ere1_vec_issue_info /* issue_info */ }; static const cpu_prefetch_tune ampere1_prefetch_tune = diff --git a/gcc/config/aarch64/tuning_models/ampere1b.h b/gcc/config/aarch64/tuning_models/ampere1b.h index b84713b53668..8ba434d27bbf 100644 --- a/gcc/config/aarch64/tuning_models/ampere1b.h +++ b/gcc/config/aarch64/tuning_models/ampere1b.h @@ -57,6 +57,36 @@ static const advsimd_vec_cost ampere1b_advsimd_vector_cost = 1 /* store_cost */ }; +static const aarch64_scalar_vec_issue_info ampere1b_scalar_issue_info = +{ + 3, /* loads_stores_per_cycle */ + 1, /* stores_per_cycle */ + 4, /* general_ops_per_cycle */ + 0, /* fp_simd_load_general_ops */ + 1 /* fp_simd_store_general_ops */ +}; + +static const aarch64_advsimd_vec_issue_info ampere1b_advsimd_issue_info = +{ + { + 2, /* loads_stores_per_cycle */ + 2, /* stores_per_cycle */ + 4, /* general_ops_per_cycle */ + 0, /* fp_simd_load_general_ops */ + 1 /* fp_simd_store_general_ops */ + }, + 2, /* ld2_st2_general_ops */ + 2, /* ld3_st3_general_ops */ + 3 /* ld4_st4_general_ops */ +}; + +static const aarch64_vec_issue_info ampere1b_vec_issue_info = +{ + &ere1b_scalar_issue_info, + &ere1b_advsimd_issue_info, + nullptr /* sve */ +}; + /* Ampere-1B costs for vector insn classes. */ static const struct cpu_vector_cost ampere1b_vector_cost = { @@ -68,7 +98,7 @@ static const struct cpu_vector_cost ampere1b_vector_cost = 1, /* cond_not_taken_branch_cost */ &ere1b_advsimd_vector_cost, /* advsimd */ nullptr, /* sve */ - nullptr /* issue_info */ + &ere1b_vec_issue_info /* issue_info */ }; static const struct tune_params ampere1b_tunings = diff --git a/gcc/testsuite/gcc.target/aarch64/ampere1-reduction-unroll-1.c b/gcc/testsuite/gcc.target/aarch64/ampere1-reduction-unroll-1.c new file mode 100644 index 000000000000..61ab57304894 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/ampere1-reduction-unroll-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -mcpu=ampere1" } */ + +/* The ampere1 family used a nullptr for the vector issue-info struct, so + aarch64_vector_costs::determine_suggested_unroll_factor returned 1 at the + `if (!vec_issue) return 1;' guard and reduction loops were never + multi-accumulator-unrolled. With issue_info populated, a unit-stride FP + dot product widens to a suggested unroll factor of 4 and emits four + independent `fmla v.4s' accumulator chains in the inner loop. */ + +float +dot (const float *a, const float *b, int n) +{ + float s = 0.0f; + for (int i = 0; i < n; i++) + s += a[i] * b[i]; + return s; +} + +/* { dg-final { scan-assembler-times {\tfmla\tv[0-9]+\.4s} 4 } } */