s390: Optimize bitwise operations by preferring IOR over PLUS
Improves s390 code generation for bitwise OR operations by prioritizing IOR over PLUS to generate more efficient instructions.
This commit refactors the s390 target’s instruction selection for bitwise OR operations on word and SImode values. Previously, the generic optab expander favored PLUS over IOR, leading to less efficient code. By explicitly choosing IOR, the compiler can now generate more compact and faster instructions, such as stc for storing, instead of a sequence involving load, logical AND, addition, and store when PLUS was used.
In Details
For word_mode and SImode, the generic aop optab expander defaults to PLUS. On s390, this leads to suboptimal code generation, particularly for operations like (*p & ~0xffu) | (x & 0xff). This patch modifies the s39q target's aop<mode>3 pattern to expand into an IOR instead of PLUS, leveraging efficient instructions like stc and avoiding unnecessary loads and additions that occur with PLUS expansion due to the lack of carry information at the RTL level.
- optab
- A table within GCC that maps generic operations (like addition, bitwise OR) to target-specific instruction sequences or patterns.
- SImode
- GCC's internal representation mode for a single integer (typically 32 bits).
- RTL
- Register Transfer Language, an intermediate representation used by GCC to represent code before it is translated into machine code.