From patchwork Sun Mar 29 23:17:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 132434 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 460304B9DB4A for ; Sun, 29 Mar 2026 23:21:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 460304B9DB4A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=VykG6mdG X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) by sourceware.org (Postfix) with ESMTPS id 72B9C4BA23ED; Sun, 29 Mar 2026 23:18:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72B9C4BA23ED Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.dev ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 72B9C4BA23ED Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774826302; cv=none; b=omcqYb6CXbkxQKA0sEvZGydix+pmSiHPt6noUGNrvsF/J7kOEZgCULWKyPsupl+OvtRsq7TMAF4ZZdbOOhuUmA5+L8zxPDjEF0QaKKaMf0aKVe/Yp8IJCtZiAvtLxvNnEujpODmCUCOzEf4dHvQZvijfwg0f2FtfWgHWhCM5ihc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774826302; c=relaxed/simple; bh=CnGN7JwJ7kbAxmAgacauVbnco4sGpvlvvIjkoRzWM/A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=E1T/I83GuU2wGAE1IuZWiioBecoKcf2f0S3Dc1dlxf+01e1KXY4greVp/5wdMToX6SGFAPofJimh1ZdwghgRrCaoNnQQ0mwmaL5su7fFQ2bdQ3Ndi0IUl4AU5F94KhptHuenaBl0ZgAGhgddF8PZyrd8m8sxxvcrW75U0ntn47U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72B9C4BA23ED X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774826300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e65kqNr8I+VQUVC14KzLrcdGGFM0Aoun3ZbxrXaN9fw=; b=VykG6mdGt/PPqoMWpqgnfRF3OmvlLu7tuUGaQ0yEw4KAX+rC8BU1id2jgyBbab7m4XaTmI fZwlZ90qqkf4E3IYi3ejsSumm3I6ey6ySSWkqqMqP+PQtIKRa4wedOkzdIEmLMJXqeWBXx 56GRk7cPbrDcUqpW6fVlUjH/ndoyOyc= From: Vineet Gupta To: bpf@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org, jose.marchesi@oracle.com, ast@kernel.org, Eduard Zingerman , Yonghong Song , Vineet Gupta Subject: [PATCH 3/3] bpf: PROMOTE_MODE to SI not DI [PR124419] [do-not-merge] Date: Sun, 29 Mar 2026 16:17:54 -0700 Message-ID: <20260329231754.2325557-4-vineet.gupta@linux.dev> In-Reply-To: <20260329231754.2325557-1-vineet.gupta@linux.dev> References: <20260329231754.2325557-1-vineet.gupta@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED 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 Since BPF ISA allows 32-bit ops and extensions, smaller types can be safely promoted to SImode (vs. DImode), thus following - M = DImode; \ + M = SImode; Also it is desirable to keep SImode regs as is, thus promotion only needs to be done for sub SImode values (vs. DImode), thus following - && GET_MODE_SIZE (M) < 8) \ + && GET_MODE_SIZE (M) < 4) \ This helps generate more wN regs. This is also part of the ABI change to be addressed in PR/124171. However currently this causes additional selftest failures which I'm investigating, but figured I'll send it with the rest of the series on same theme. PR target/124419 gcc/ChangeLog: * config/bpf/bpf.h (PROMOTE_MODE): Promote modes smaller than SImode to SImode. gcc/testsuite/ChangeLog: * gcc.target/bpf/btfext-lineinfo.c: Adjust for codegen changes. Signed-off-by: Vineet Gupta --- gcc/config/bpf/bpf.h | 7 +++---- gcc/testsuite/gcc.target/bpf/btfext-lineinfo.c | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h index c8dad55fd4c4..32730628febe 100644 --- a/gcc/config/bpf/bpf.h +++ b/gcc/config/bpf/bpf.h @@ -43,14 +43,13 @@ #define BITS_PER_WORD 64 #define UNITS_PER_WORD 8 -/* When storing an integer whose size is less than 64-bit in a - register, promote it to a DImode. */ +/* Promote integer modes smaller than a word to SImode. */ #define PROMOTE_MODE(M, UNSIGNEDP, TYPE) \ do \ { \ if (GET_MODE_CLASS (M) == MODE_INT \ - && GET_MODE_SIZE (M) < 8) \ - M = DImode; \ + && GET_MODE_SIZE (M) < 4) \ + M = SImode; \ } while (0) /* Align argument parameters on the stack to 64-bit, at a minimum. */ diff --git a/gcc/testsuite/gcc.target/bpf/btfext-lineinfo.c b/gcc/testsuite/gcc.target/bpf/btfext-lineinfo.c index dc1c297d663e..9d3a68e2ddef 100644 --- a/gcc/testsuite/gcc.target/bpf/btfext-lineinfo.c +++ b/gcc/testsuite/gcc.target/bpf/btfext-lineinfo.c @@ -38,12 +38,12 @@ int bar_func (struct T *t) /* { dg-final { scan-assembler-times "btfext-lineinfo\.c.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */ /* { dg-final { scan-assembler-times "4byte\[\t \]+\.LFB.\[\t \]+# insn_label" 2 } } */ -/* { dg-final { scan-assembler-times "4byte\[\t \]+LI.\[\t \]+# insn_label" 6 } } */ +/* { dg-final { scan-assembler-times "4byte\[\t \]+LI.\[\t \]+# insn_label" 8 } } */ -/* { dg-final { scan-assembler-times "# \\(line, col\\)" 8 } } */ +/* { dg-final { scan-assembler-times "# \\(line, col\\)" 10 } } */ /* { dg-final { scan-assembler-times "# \\(line, col\\) \\(18, 5\\)" 1 } } */ -/* { dg-final { scan-assembler-times "# \\(line, col\\) \\(20, 10\\)" 1 } } */ -/* { dg-final { scan-assembler-times "# \\(line, col\\) \\(21, 18\\)" 1 } } */ +/* { dg-final { scan-assembler-times "# \\(line, col\\) \\(20, 10\\)" 2 } } */ +/* { dg-final { scan-assembler-times "# \\(line, col\\) \\(21, 18\\)" 2 } } */ /* { dg-final { scan-assembler-times "# \\(line, col\\) \\(22, 1\\)" 1 } } */ /* { dg-final { scan-assembler-times "# \\(line, col\\) \\(25, 5\\)" 1 } } */ /* { dg-final { scan-assembler-times "# \\(line, col\\) \\(28, 7\\)" 1 } } */