How to add 256 byte sized opaque mode in gcc
Avinash Jayakar proposes a patch to dynamically size the mode_unit_size array in GCC based on machine modes, addressing concerns about compile times.
Avinash Jayakar has submitted a patch that dynamically sizes the mode_unit_size array based on the maximum bytesize declared in machine modes, following suggestions from Jakub Jelinek and Richard Biener. This addresses concerns that the change might increase compile times, particularly for powerpc64le. The patch also incorporates style suggestions regarding brace usage.
- proposer
Presents a patch to dynamically size the mode_unit_size array and inquires about potential compile time impacts.
“I have attached the proposed patch based on your input to dynamically size the mode_unit_size array based on maximum bytesize declared in machine modes. Please do let me know if any tests are required for this before sending to gcc-patches? Also as you mentioned these lookups happen quite often in compilation, so introducing this new mode could potentially increase compile times for powerpc64l…”
- reviewer
Suggests using unsigned short for the array and proposes dynamically sizing it based on genmodes to reduce cache footprint.
“I'd use unsigned short, it's important to not use an overly large data structure for those common lookups to reduce cache footprint. We could possibly even dynamically size the component from genmodes?”
- contributor
Acknowledges Richard Biener's feedback and agrees to update the code style.
“Sure I will update this.”
- reviewer
Provided further review comments on the patch, including a code snippet modification.
“+ unsigned int max_type_size = 0; + for_all_modes (c, m) + { + if (max_type_size < m->bytesize) + max_type_size ”
Technical Tradeoffs
- Balancing the memory efficiency of a dynamically sized array against the potential overhead of calculating the size at compile time.
- Ensuring the dynamic sizing logic correctly handles all relevant machine modes without introducing new bugs or performance regressions.
In Details
This patch modifies how GCC handles machine modes by dynamically sizing the mode_unit_size array. Previously, a fixed size might have been used, potentially leading to wasted space or inefficiency. The proposal aims to optimize this by determining the required size based on the actual byte sizes of defined machine modes, with a specific focus on potential performance implications for the powerpc64le architecture.
- machine mode
- In GCC, a machine mode represents a data type that the target machine can operate on. Examples include modes for integers of various sizes (e.g.,
SImodefor 32-bit signed integers,DImodefor 64-bit), floating-point numbers, and vector types. - mode_unit_size
- An internal GCC array or data structure that likely stores information about the size of individual units within a machine mode. This is relevant for operations that involve breaking down or composing data types.
- powerpc64le
- A specific variant of the PowerPC 64-bit architecture, using little-endian byte order. It is a common architecture for servers and high-performance computing.
- cache footprint
- Refers to the amount of CPU cache memory that is occupied by a data structure or program. A smaller cache footprint is generally desirable for performance as it increases the likelihood of data being found in the faster cache.