From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7918) id A71333858402; Tue, 28 Nov 2023 12:46:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A71333858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701175607; bh=EWQU1/z08ugtOs4L5R/ydTAcESD5FoFQjv3XTKdBV1E=; h=From:To:Subject:Date:From; b=azlE55lcI8RxC0UAfVGODRmm4QSdFOxk6KhETJ3awELSiQdDB70F6Ovp18YAj8kGK LKsDf6J8NbdRtodUwc8Eztx0BjPZci9k6BizIeTE1bBShJ5o8QK7Drvhf8C29XPX/B 2ztrENAZYBY5R1wras2OzZK7eoDTxKnEdqP/a+4k= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Cupertino Miranda To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-5923] bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes. X-Act-Checkin: gcc X-Git-Author: Cupertino Miranda X-Git-Refname: refs/heads/master X-Git-Oldrev: 6c8f2d3a08bc013ddb31f7fccd7136751a1460ed X-Git-Newrev: 19cc5857e2cb0fb7c637a35a956f902d44286c2d Message-Id: <20231128124647.A71333858402@sourceware.org> Date: Tue, 28 Nov 2023 12:46:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:19cc5857e2cb0fb7c637a35a956f902d44286c2d commit r14-5923-g19cc5857e2cb0fb7c637a35a956f902d44286c2d Author: Cupertino Miranda Date: Fri Nov 10 16:42:13 2023 +0000 bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes. This patch forces __builtin_memcmp calls upto data sizes of 1024 to become inline in caller. This is a requirement by BPF and it mimics the default behaviour of the clang BPF implementation. gcc/ChangeLog: * config/bpf/bpf.cc (bpf_use_by_pieces_infrastructure_p): Added function to bypass default behaviour. * config/bpf/bpf.h (COMPARE_MAX_PIECES): Defined to 1024 bytes. Diff: --- gcc/config/bpf/bpf.cc | 16 ++++++++++++++++ gcc/config/bpf/bpf.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc index 223a43cbbb3..4bfba289546 100644 --- a/gcc/config/bpf/bpf.cc +++ b/gcc/config/bpf/bpf.cc @@ -1117,6 +1117,22 @@ bpf_small_register_classes_for_mode_p (machine_mode mode) #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \ bpf_small_register_classes_for_mode_p +static bool +bpf_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size, + unsigned int align ATTRIBUTE_UNUSED, + enum by_pieces_operation op, + bool speed_p) +{ + if (op != COMPARE_BY_PIECES) + return default_use_by_pieces_infrastructure_p (size, align, op, speed_p); + + return size <= COMPARE_MAX_PIECES; +} + +#undef TARGET_USE_BY_PIECES_INFRASTRUCTURE_P +#define TARGET_USE_BY_PIECES_INFRASTRUCTURE_P \ + bpf_use_by_pieces_infrastructure_p + /* Finally, build the GCC target. */ struct gcc_target targetm = TARGET_INITIALIZER; diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h index 82702aa7b6b..1f177ec4c4e 100644 --- a/gcc/config/bpf/bpf.h +++ b/gcc/config/bpf/bpf.h @@ -489,6 +489,11 @@ enum reg_class locations. */ #define MOVE_MAX 8 +/* Allow upto 1024 bytes moves to occur using by_pieces + infrastructure. This mimics clang behaviour when using + __builtin_memcmp. */ +#define COMPARE_MAX_PIECES 1024 + /* An alias for the machine mode for pointers. */ #define Pmode DImode