* [PATCH] bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes.
@ 2023-11-13 22:37 Cupertino Miranda
2023-11-24 16:54 ` Jose E. Marchesi
0 siblings, 1 reply; 4+ messages in thread
From: Cupertino Miranda @ 2023-11-13 22:37 UTC (permalink / raw)
To: gcc-patches; +Cc: jose.marchesi, elena.zannoni, david.faust, Cupertino Miranda
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.
---
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 a0956a069729..764a3e487cb6 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -1115,6 +1115,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 82702aa7b6ba..1f177ec4c4ef 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
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes.
2023-11-13 22:37 [PATCH] bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes Cupertino Miranda
@ 2023-11-24 16:54 ` Jose E. Marchesi
2023-11-28 12:46 ` Cupertino Miranda
2023-11-28 12:54 ` Cupertino Miranda
0 siblings, 2 replies; 4+ messages in thread
From: Jose E. Marchesi @ 2023-11-24 16:54 UTC (permalink / raw)
To: Cupertino Miranda; +Cc: gcc-patches, elena.zannoni, david.faust
Hi Cuper.
Sorry, I missed this patch last week.
This is OK.
Thanks!
> 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.
> ---
> 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 a0956a069729..764a3e487cb6 100644
> --- a/gcc/config/bpf/bpf.cc
> +++ b/gcc/config/bpf/bpf.cc
> @@ -1115,6 +1115,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 82702aa7b6ba..1f177ec4c4ef 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes.
2023-11-24 16:54 ` Jose E. Marchesi
@ 2023-11-28 12:46 ` Cupertino Miranda
2023-11-28 12:54 ` Cupertino Miranda
1 sibling, 0 replies; 4+ messages in thread
From: Cupertino Miranda @ 2023-11-28 12:46 UTC (permalink / raw)
To: Jose E. Marchesi; +Cc: gcc-patches, elena.zannoni, david.faust
Thanks! Committed !
Jose E. Marchesi writes:
> Hi Cuper.
>
> Sorry, I missed this patch last week.
> This is OK.
>
> Thanks!
>
>> 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.
>> ---
>> 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 a0956a069729..764a3e487cb6 100644
>> --- a/gcc/config/bpf/bpf.cc
>> +++ b/gcc/config/bpf/bpf.cc
>> @@ -1115,6 +1115,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 82702aa7b6ba..1f177ec4c4ef 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes.
2023-11-24 16:54 ` Jose E. Marchesi
2023-11-28 12:46 ` Cupertino Miranda
@ 2023-11-28 12:54 ` Cupertino Miranda
1 sibling, 0 replies; 4+ messages in thread
From: Cupertino Miranda @ 2023-11-28 12:54 UTC (permalink / raw)
To: Jose E. Marchesi; +Cc: gcc-patches, elena.zannoni, david.faust
Thanks! Committed!
Jose E. Marchesi writes:
> Hi Cuper.
>
> Sorry, I missed this patch last week.
> This is OK.
>
> Thanks!
>
>> 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.
>> ---
>> 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 a0956a069729..764a3e487cb6 100644
>> --- a/gcc/config/bpf/bpf.cc
>> +++ b/gcc/config/bpf/bpf.cc
>> @@ -1115,6 +1115,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 82702aa7b6ba..1f177ec4c4ef 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-28 12:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 22:37 [PATCH] bpf: Forces __buildin_memcmp not to generate a call upto 1024 bytes Cupertino Miranda
2023-11-24 16:54 ` Jose E. Marchesi
2023-11-28 12:46 ` Cupertino Miranda
2023-11-28 12:54 ` Cupertino Miranda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).