genattrtab: Deduplicate attribute value simplifications
Reduces redundant work in attribute table generation by simplifying values only once per unique set.
This commit enhances genattrtab’s optimize_attrs function by avoiding repeated simplifications of attribute values for instruction codes that share the same attribute alternatives and values. A hash table now groups identical instruction codes, ensuring simplification occurs only for the first instance. Subsequent identical codes reuse the computed values, significantly speeding up genattrtab for various backends, especially AArch64 and RISC-V.
In Details
The optimize_attrs pass in genattrtab.cc previously re-simplified attribute values for instruction codes that had identical attribute sets. This patch introduces a hash table keyed by attribute values and alternatives to group such instruction codes. Simplification is now performed only once per group, with other instruction codes inheriting the results. This drastically cuts down computation, particularly for targets with many repeated attribute value patterns.
- genattrtab
- A GCC internal tool that generates attribute tables used by various backends for instruction selection and scheduling.
- optimize_attrs
- A function within genattrtab that simplifies attribute values based on other attributes for a given instruction code.