Improve vector conversion folding by handling NOP and sign conversions correctly.
Vector conversion optimizations now correctly handle no-operation and sign-preserving conversions.
This commit refines vector conversion optimizations by addressing issues in supportable_convert_operation and vectorizable_conversion. It ensures that no-operation (NOP) conversions and sign-preserving conversions are correctly handled, preventing test suite failures. The changes allow NOP_EXPR and VIEW_CONVERT_EXPR for same-mode types, and modify vectorizable_conversion to prefer VIEW_CONVERT_EXPR for vector types, ensuring that these conversions are recognized and optimized appropriately without introducing incorrect behavior.
In Details
Updates optabs-tree.cc, tree-ssa-forwprop.cc, and tree-vect-stmts.cc to improve vector conversion folding, targeting PR middle-end/126788. Specifically, supportable_convert_operation now allows NOP_EXPR and VIEW_CONVERT_EXPR for same modes, addressing cases where vectorizable_conversion previously emitted VIEW_CONVERT_EXPR for same-mode types instead of NOP_EXPR. This change ensures that sign-conversions, previously routed through vectorizable_assignment, are now handled by vectorizable_conversion, preventing testsuite failures caused by incorrect folding of vector types.
- Vectorization
- An optimization process where the compiler transforms scalar code (operating on single data items) into vector code (operating on multiple data items simultaneously using SIMD instructions).
- NOP_EXPR
- A GCC internal representation for a no-operation expression, indicating that no change or computation is actually performed.
- VIEW_CONVERT_EXPR
- A GCC internal representation for a type conversion that conceptually views the data in a different type without changing its underlying representation. This is often used for type casts.
- Sign conversion
- A type conversion that preserves the sign of the number, such as converting a signed 16-bit integer to a signed 32-bit integer.
- Canonical representation
- A standardized or preferred form for representing a particular construct or value within the compiler's intermediate representation.