[Bug c/93837] New: overly complicated code in c_finish_omp_declare_variant
roland.illig at gmx dot de
gcc-bugzilla@gcc.gnu.org
Wed Feb 19 20:57:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93837
Bug ID: 93837
Summary: overly complicated code in
c_finish_omp_declare_variant
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: roland.illig at gmx dot de
Target Milestone: ---
> else if (fndecl_built_in_p (variant)
> && (strncmp (IDENTIFIER_POINTER (DECL_NAME (variant)),
> "__builtin_", strlen ("__builtin_")) == 0
> || strncmp (IDENTIFIER_POINTER (DECL_NAME (variant)),
> "__sync_", strlen ("__sync_")) == 0
> || strncmp (IDENTIFIER_POINTER (DECL_NAME (variant)),
> "__atomic_", strlen ("__atomic_")) == 0))
Why not simply define a function str_startswith and rewrite the code to:
> str_startswith (IDENTIFIER_POINTER (DECL_NAME (variant)), "__builtin_")
> || str_startswith (IDENTIFIER_POINTER (DECL_NAME (variant)), "__sync_")
> || str_startswith (IDENTIFIER_POINTER (DECL_NAME (variant)), "__atomic_")
This would make it even more obvious that an additional CSE pass would make the
code even easier to read:
> const char *variant_name = IDENTIFIER_POINTER (DECL_NAME (variant));
> if (str_startswith(variant_name, "__builtin_")
> || str_startswith(variant_name, "__sync_")
> || str_startswith(variant_name, "__atomic_"))
Is there any reason why you chose to write the code in the complicated and hard
to read way?
More information about the Gcc-bugs
mailing list