mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 12:00:11 -05:00
7e7091bfa87dab24d36c50233ca04cb6319c5b91
The ARC builtin functions __builtin_arc_ffs and __builtin_arc_fls perform pure mathematical operations equivalent to the standard GCC __builtin_ffs function, which is marked with the const attribute. However, the ARC target-specific versions were not marked as const, preventing compiler optimizations like common subexpression elimination. Extend the ARC builtin infrastructure to support function attributes and mark the appropriate mathematical builtins as const: - __builtin_arc_ffs: Find first set bit (const) - __builtin_arc_fls: Find last set bit (const) - __builtin_arc_norm: Count leading zeros (const) - __builtin_arc_normw: Count leading zeros for 16-bit (const) - __builtin_arc_swap: Endian swap (const) gcc/ChangeLog: * config/arc/builtins.def: Add ATTRS parameter to DEF_BUILTIN macro calls. Mark mathematical builtins (FFS, FLS, NORM, NORMW, SWAP) with attr_const, leave others as NULL_TREE. * config/arc/arc.cc: Add support for builtin function attributes. Create attr_const using tree_cons. Update DEF_BUILTIN macro to pass ATTRS parameter to add_builtin_function. gcc/testsuite/ChangeLog: * gcc.target/arc/builtin_fls_const.c: New test. Verify that const attribute enables CSE optimization for mathematical ARC builtins by checking that duplicate calls are eliminated and results are optimized to shift operations. Signed-off-by: Kees Cook <kees@kernel.org>
…
…
…
…
…
…
…
…
…
…
…
…
…
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.
Description
Languages
C++
30.7%
C
30%
Ada
14.5%
D
6.1%
Go
5.7%
Other
12.5%