From patchwork Sun Mar 29 23:17:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 132432 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 133FF4BA902E for ; Sun, 29 Mar 2026 23:20:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 133FF4BA902E Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ik6gnZNk X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) by sourceware.org (Postfix) with ESMTPS id BB6C84BA23E5 for ; Sun, 29 Mar 2026 23:18:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB6C84BA23E5 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 BB6C84BA23E5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=95.215.58.170 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774826296; cv=none; b=ULFdGQcd1xa8F1rn1aI5ag8+yAQfDmC2AzZmWXarmAaauoIGOuRRnk9ULxq1r7vMznnszrTMHxSRz00wDzUbyGX5+dW2ITm2P73RI9sVoE1+d7ZUSjqaXAmLhBLDG30CD4bbp0KZhvRoVzYE32hK02sCli8i3uPS/9X3fwmp+LU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774826296; c=relaxed/simple; bh=bVQHD0kT6Nah09BJqpuFnPUoa4z9kuAuedsjH8sUtK4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ts5RuOp7e8gElV9TV8YguDX0Cm5uYnpwIYUPTxtW9K1UD3uFXsNPTUInOiyxFZnD1fddVORyaGUQLRJ9VK2alLKI6iE0cJSBd2LbM671502LJx6xQWWjARhfD/MdBTU+0oTO7gmz+eLEQNU3Sc0mdwcRCjTZEXvCc+nC3A4k1IA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB6C84BA23E5 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=1774826294; 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=UqQaxvYI6GVhWsWm8lKtteXS3cPKTKgZKFDh49/mNDs=; b=ik6gnZNkaPHe+/VE2v1oId0toaHHCW7LxmfrJOpHDMN+oiZ6FmO1oo3UgFlsEv2bv33ESD l4Q1oJkD6mPiy8Un4BNH34i9TAvLLCeTA/DmpKEgkbyqC388dfH4FPCiEmcnOYvP0Xumls n7lwEhiKrML+yYXs/v0OAs4lV6gX414= 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 1/3] bpf: md: Enable zero_extend{hi, qi}di2 to generate wN regs ... Date: Sun, 29 Mar 2026 16:17:52 -0700 Message-ID: <20260329231754.2325557-2-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=-6.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, MEDICAL_SUBJECT, 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 ... by adjusting the asm template reg string to 'W', similar to commit gbd275e81812c for zero_extendsidi2. However unike that change, this is not a bug fix: zero_extendsidi2 relies on wN reg move to achieve the 32->64 semantics. A {8,16}->64 extension needs to be emulated anyways by masking out extra bits so the reg used is not imp. However wN reg based codegen is still preferable in general: - It is easier on verifier as it has to track fewer bits and avoids corner cases which could trip it up for false positives. - Better native codegen as upper bits are guarateed to be zero and can leverage target ISA mechanisms to achieve that mostly for free. - Better nativ codegen on 32-bit targets which need to use 2 regs for rN regs. gcc/ChangeLog: * config/bpf/bpf.md (zero_extendhidi2): Add alternates for alu32 and use 'W' for reg operands. (zero_extendqidi2): Ditto. gcc/testsuite/ChangeLog: * gcc.target/bpf/zero-ext.c: Add tests for {HI,QI}mode values. Signed-off-by: Vineet Gupta --- gcc/config/bpf/bpf.md | 8 ++++---- gcc/testsuite/gcc.target/bpf/zero-ext.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md index c2c3152b5d7c..a2bceb8998d7 100644 --- a/gcc/config/bpf/bpf.md +++ b/gcc/config/bpf/bpf.md @@ -279,8 +279,8 @@ (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "0,r,q")))] "" "@ - {and\t%0,0xffff|%0 &= 0xffff} - *return bpf_output_move (operands, \"{mov\t%0,%1\;and\t%0,0xffff|%0 = %1;%0 &= 0xffff}\"); + *return bpf_has_alu32 ? \"{and32\t%0,0xffff|%W0 &= 0xffff}\" : \"{and\t%0,0xffff|%0 &= 0xffff}\"; + *return bpf_output_move (operands, bpf_has_alu32 ? \"{mov\t%0,%1\;and\t%0,0xffff|%W0 = %W1;%W0 &= 0xffff}\" : \"{mov\t%0,%1\;and\t%0,0xffff|%0 = %1;%0 &= 0xffff}\"); *return bpf_output_move (operands, \"{ldxh\t%0,%1|%0 = *(u16 *) %1}\");" [(set_attr "type" "alu,alu,ldx")]) @@ -289,8 +289,8 @@ (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "0,r,q")))] "" "@ - {and\t%0,0xff|%0 &= 0xff} - *return bpf_output_move (operands, \"{mov\t%0,%1\;and\t%0,0xff|%0 = %1;%0 &= 0xff}\"); + *return bpf_has_alu32 ? \"{and32\t%0,0xff|%W0 &= 0xff}\" : \"{and\t%0,0xff|%0 &= 0xff}\"; + *return bpf_output_move (operands, bpf_has_alu32 ? \"{mov\t%0,%1\;and\t%0,0xff|%W0 = %W1;%W0 &= 0xff}\" : \"{mov\t%0,%1\;and\t%0,0xff|%0 = %1;%0 &= 0xff}\"); *return bpf_output_move (operands, \"{ldxb\t%0,%1|%0 = *(u8 *) %1}\");" [(set_attr "type" "alu,alu,ldx")]) diff --git a/gcc/testsuite/gcc.target/bpf/zero-ext.c b/gcc/testsuite/gcc.target/bpf/zero-ext.c index a57c7dc521f0..b6ab7dab8bc0 100644 --- a/gcc/testsuite/gcc.target/bpf/zero-ext.c +++ b/gcc/testsuite/gcc.target/bpf/zero-ext.c @@ -2,6 +2,8 @@ /* { dg-options "-O2 -mcpu=v4" } */ int bar_int(void); +short bar_short(void); +_Bool bar_bool(void); int foo_int(void) { if (bar_int() != 1) return 0; else return 1; @@ -9,3 +11,17 @@ int foo_int(void) { /* { dg-final { scan-assembler-not {r0 = r0} } } */ /* { dg-final { scan-assembler-times {w0 = w0} 1 } } */ + +int trigger_zext_hidi(void) { + if (bar_short() != 1) return 0; else return 1; +} + +/* { dg-final { scan-assembler-not {r0 &= 0xffff} } } */ +/* { dg-final { scan-assembler-times {w0 &= 0xffff} 1 } } */ + +int trigger_zext_qidi(void) { + if (bar_bool() != 0) return 0; else return 1; +} + +/* { dg-final { scan-assembler-not {r0 &= 0xff\n} } } */ +/* { dg-final { scan-assembler-times {w0 &= 0xff\n} 1 } } */ From patchwork Sun Mar 29 23:17:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 132433 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 6B8874B9DB43 for ; Sun, 29 Mar 2026 23:20:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B8874B9DB43 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=lpdEHAsB X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by sourceware.org (Postfix) with ESMTPS id 248B64BA23ED for ; Sun, 29 Mar 2026 23:18:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 248B64BA23ED 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 248B64BA23ED Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=95.215.58.173 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774826299; cv=none; b=ulYLLZdwcs27Koscswdqnpedjc0MaQiYmXrDubhidgd/5Lxlrmf+JKc+Z1o3Z/6yy8CiNDwoblNiG0EmO1zfV9QM5epxKxB1Di3xnz6FJ58lkM/8Id+TrgAuow8RrBRprXf31pOswdytAw66ijF0AqL/o5k4dKrVap7YQJYSdjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774826299; c=relaxed/simple; bh=cIbQOaSYrVZISbxuMDE4SfzvjcZs3IQ5j5mBnPoesBk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XO4CR4FhK5xKBfokhoi1kktJUsjiZy8Jt4slbTywFmoIgzwHo/DKX9qVpNdBX/6P9gBLfBZKD6lgQQAC3h4EYCZYn3NrGdHO79iz69dxTLjyppYPATcwnLOsXj6mFQ4iVtgDqzlPlAhI/ylT3O9ouNrp12jd5zjJfE4ag9iMXWc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 248B64BA23ED 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=1774826296; 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=OCWFHbhNFJ+ktfM3IV2/r4Ay6c0kVwLdRShv/ZKsH9w=; b=lpdEHAsBxBE+pnD5K5Tz+PvMmI1NEE43Zn6Otx22gnqQ/kfcx+qAMLuzmDxsJ4yBhjIMer +FzAoblp7UyKAK4P49fjjmEvdcpXE04r7BwTlCOCsJwkR0hhULRFgPaeHijkwbYQOvmP7V Dbbzqyhm+rqWA8rLwy/auunWTXcmjhY= 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 , Vineet Gupta Subject: [PATCH 2/3] bpf: md: fix "*movsi" to generate wN regs [PR124688] Date: Sun, 29 Mar 2026 16:17:53 -0700 Message-ID: <20260329231754.2325557-3-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=-6.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, MEDICAL_SUBJECT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=unavailable 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 From: Vineet Gupta movsi currently only generates DImode rN regs, despite RTL being SImode. | (insn 14 5 11 (set (reg:SI 1 %r1 [23]) | (reg:SI 0 %r0)) {*movsi} | (expr_list:REG_DEAD (reg:SI 0 %r0) | (nil))) generates | r1 = r0 as opposed to | w1 = w0 This is not just issue of taste or getting more wN regs. As illustrated by test, this can be a correctness issue where mov needs to zero out the upper bits. Again the issue is asm teplmate of pattern missing 'w' specifier, leading bpf_print_register() to only generate 64-bit rN regs. Using 'w' allows either wN/rN reg depending on the mode. PR target/124688 gcc/ChangeLog: * config/bpf/bpf.md (*movsi): Add 'w' to asm template. gcc/testsuite/ChangeLog: * gcc.target/bpf/ret-reuse-arg-1.c: New test. Signed-off-by: Vineet Gupta --- gcc/config/bpf/bpf.md | 10 +++++----- gcc/testsuite/gcc.target/bpf/ret-reuse-arg-1.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/bpf/ret-reuse-arg-1.c diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md index a2bceb8998d7..e6776a94e7e4 100644 --- a/gcc/config/bpf/bpf.md +++ b/gcc/config/bpf/bpf.md @@ -383,11 +383,11 @@ (match_operand:MM 1 "mov_src_operand" " q,rIc,BC,r,I"))] "" "@ - *return bpf_output_move (operands, \"{ldx\t%0,%1|%0 = *( *) %1}\"); - *return bpf_output_move (operands, \"{mov\t%0,%1|%0 = %1}\"); - *return bpf_output_move (operands, \"{lddw\t%0,%1|%0 = %1 ll}\"); - *return bpf_output_move (operands, \"{stx\t%0,%1|*( *) %0 = %1}\"); - *return bpf_output_move (operands, \"{st\t%0,%1|*( *) %0 = %1}\");" + *return bpf_output_move (operands, \"{ldx\t%0,%1|%w0 = *( *) %w1}\"); + *return bpf_output_move (operands, \"{mov\t%0,%1|%w0 = %w1}\"); + *return bpf_output_move (operands, \"{lddw\t%0,%1|%w0 = %w1 ll}\"); + *return bpf_output_move (operands, \"{stx\t%0,%1|*( *) %w0 = %w1}\"); + *return bpf_output_move (operands, \"{st\t%0,%1|*( *) %w0 = %w1}\");" [(set_attr "type" "ldx,alu,alu,stx,st")]) ;;;; Shifts diff --git a/gcc/testsuite/gcc.target/bpf/ret-reuse-arg-1.c b/gcc/testsuite/gcc.target/bpf/ret-reuse-arg-1.c new file mode 100644 index 000000000000..6d0a4f280cd7 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/ret-reuse-arg-1.c @@ -0,0 +1,14 @@ +/* Return value of first call is arg to second call. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=v4" } */ + +int ret_int (); +void arg_int (int); + +void foo () { + arg_int(ret_int ()); +} + +/* { dg-final { scan-assembler-not {r1 = r0} } } */ +/* { dg-final { scan-assembler-times {w1 = w0} 1 } } */ 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 } } */