Add saturating subtract support to PowerPC
GCC now recognizes patterns for saturating subtract instructions on PowerPC.
GCC has added support for saturating subtract instructions that may be included in a future PowerPC architecture. Instead of relying on a specific built-in function, the compiler now automatically recognizes code patterns where a saturating subtract can be generated. This change enables more efficient handling of arithmetic operations that need to clamp results within a defined range.
In Details
This commit adds support for saturating subtract instructions (subfus<mode>, subdus<mode>) to the rs6000 backend for a future PowerPC ISA. It introduces new code iterators (gtu_geu) and instruction patterns in rs6000.md to recognize and generate these saturating operations directly, rather than relying on a user-defined built-in. This allows the compiler to optimize standard arithmetic operations into saturating variants when appropriate. New test cases saturate-subtract-1.c and saturate-subtract-2.c are added.
- saturating subtract
- A type of subtraction operation where the result is clamped to the maximum or minimum representable value if it exceeds those bounds, rather than overflowing or underflowing.
- PowerPC
- A RISC instruction set architecture developed by Apple, IBM, and Motorola. It's used in various embedded systems, servers, and historically in Apple Macintosh computers.
- GCC backend
- The part of the GCC compiler responsible for translating the compiler's intermediate representation into machine-specific assembly code for a particular target architecture.
- code iterator
- A mechanism within GCC's machine description files used to group or iterate over related instruction patterns or conditions.