Kees Cook 7e7091bfa8 arc: Add const attribute support for mathematical ARC builtins
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>
2025-11-04 17:27:58 +02:00
2025-06-03 00:18:06 +00:00
2025-11-04 00:20:26 +00:00
2025-10-31 00:22:18 +00:00
2025-08-29 00:19:55 +00:00
2025-06-23 00:16:33 +00:00
2025-10-17 00:18:48 +00:00
2025-01-02 11:59:57 +01:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-10-14 00:20:06 +00:00
2025-01-02 11:59:57 +01:00
2025-11-04 00:20:26 +00:00
2025-10-26 00:17:33 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-09-02 00:19:26 +00:00
2025-11-04 00:20:26 +00:00
2025-11-04 00:20:26 +00:00
2025-10-11 11:08:01 +02:00
2024-11-19 12:27:33 +01:00
2025-10-11 11:08:01 +02:00

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
No description provided
Readme 1.5 GiB
Languages
C++ 30.7%
C 30%
Ada 14.5%
D 6.1%
Go 5.7%
Other 12.5%