middle-end/129022 - mishandled QImode AVX512 mask in VIEW_CONVERT folding
Fixes incorrect handling of AVX512 mask types during VIEW_CONVERT folding, preventing compiler errors.
AVX512 mask vectors, which use QImode and have a TYPE_SIZE of 8, were causing issues in the fold_view_convert_vector_encoding function. This function incorrectly computed element bits for these mask types, leading to compilation errors. The fix makes the function bail out on these specific boolean vectors, falling back to a more generic VIEW_CONVERT handling that avoids the error.
In Details
The fold_view_convert_vector_encoding function in fold-const.cc mishandles AVX512 mask types (like __mask8, __mask16, __mask32, __mask64), which are represented using QImode and have a TYPE_SIZE of 8. The function's element bits computation erroneously assumes these are standard integer types, leading to incorrect folding. This patch modifies the function to detect these boolean vectors with padding and reject them, falling back to the general VIEW_CONVERT logic which handles them correctly.
- AVX512
- Advanced Vector Extensions 512. An instruction set extension for x86 microprocessors that increases the width of SIMD registers to 512 bits, allowing for wider vector operations.
- QImode
- In GCC's internal representation, a machine mode representing a single byte (8 bits).
- VIEW_CONVERT
- An operation in GCC's intermediate representation that reinterprets the bits of one type as another type, often used for type punning or vector element conversions.
- folding
- An optimization technique where constant expressions or operations are evaluated at compile time rather than at runtime.