https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116453
Bug ID: 116453 Summary: Large code when initializing array using user defined literals Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: JoernRath at gmx dot de Target Milestone: --- The following code returns a float array initialized from an array of uint32_t values which are the binary representation of the target float values. The conversion to float is done using a user defined literal. With "-O3" for every four values two instructions are generated in addition to the stored constants. This can be optimized by storing the constants below a single label and loading the data using a loop. float operator""_F(unsigned long long int float_data) { float tmp{}; std::memcpy(&tmp, &float_data, sizeof(float)); return tmp; } std::array<float, 168> foo() { std::array<float, num_entries> a = { 0x3B479C6D_F, ... ,0x3B47A0FE_F, }; return a; } See https://godbolt.org/z/7avvhYnW8 for a full example and compiler configuration.