> I don't see how this makes any sense. If TARGET_SIMD or TARGET_FP > are true, the compiler may at any time use a SIMD register for anything - > including in integer-only code.
Thanks for reviewing my proposed patch. I'm struggling to migrate the Zephyr project from GCC 12.2 to a more recent version and this is one issue causing testing regressions. I'm trying to find all cases where that happens for data types other than SIMD/FP. Do you know of other places where the compiler implicitly uses SIMD registers for integer data? > And making it the default for embedded > targets would make code slower&larger for everybody - I don't see how > that could be justified given that interrupt handlers always need special > consideration anyway and represent a tiny fraction of all code... In Zephyr, interrupt handlers are allowed to perform FP/SIMD operations. Which means we cannot use -mgeneral-regs-only. When they do use the FPU, interrupts are disabled at the first FP instruction which increases latency for nested interrupts. They need control over when FP instructions will be generated. With previous GCC versions FP instructions were only generated by the compiler when FP datatypes were involved. That's what I'm trying to get back to. There's also a performance trade-off involved here. As soon as you use FP instructions, the OS must save/restore the entire FPU on task switch. This increases task switch latency. Given that these memory operations only generate SIMD instructions in a limited set of cases (<= 256 byte copies of fixed size), and that an embedded memory system is unlikely to have a bus wider than 16 bytes, the actual performance improvement will be modest at best. Of course, applications aren't forced to use this mode; the -msimd-memops flag will restore the existing behavior, so code which is performance sensitive can regain the missing optimization. I want the default to retain the previous compiler semantics. If you don't think this default is suitable for upstream GCC, I'm happy to carry an out-of-tree patch for the Zephyr SDK. > AArch64 has -mgeneral-regs-only which does exactly what you want, > so any interrupt code can be built using that. Zephyr interrupt handlers have full access to the OS interfaces including the C library, so a huge swath of the system would need to be compiled in this mode. I discovered this issue when an interrupt handler called printf. -- -keith
signature.asc
Description: PGP signature