Fix loop mask for multi-part SIMD clone calls.
Correctly applies loop masks to all parts of multi-argument SIMD clone calls to prevent out-of-bounds lane execution.
This commit resolves an issue in vectorizable_simd_clone_call where multi-part SIMD clone calls with multiple mask arguments were incorrectly using the same loop mask for all parts. This led to lanes beyond the intended iteration count being enabled in later mask parts, causing the clone to be called on inactive lanes. The fix ensures that the correct mask part index is used when fetching the loop mask for explicit mask arguments.
In Details
PR tree-optimization/127924 exposes a bug in vectorizable_simd_clone_call when handling fully-masked loops that require multiple mask arguments per inbranch SIMD clone call. The issue stems from using the J (copy index) instead of M (mask part index) to fetch the loop mask, resulting in all mask parts being ANDed with the first loop mask. This patch corrects the loop mask index to M to ensure correct lane masking.
- SIMD
- Single Instruction, Multiple Data. A type of parallel processing where a single instruction operates on multiple data points simultaneously. Often used for accelerating graphics, scientific simulations, and multimedia processing.
- SIMD clone
- A function or code path that is specifically designed to be vectorized, often by being called within a loop that is also being vectorized. 'Clone' here refers to a specialized version adapted for SIMD execution.
- inbranch
- Refers to a function call that is inlined or otherwise integrated directly within the execution path of its caller, often to facilitate optimizations like loop unrolling or vectorization.
- AVX512
- An extension to the x86 instruction set architecture that provides 512-bit wide SIMD registers and instructions, allowing for more data parallelism.
- loop mask
- A mask used in vectorized loops to control which elements are processed in each iteration. It ensures that only valid data within the current iteration bounds is operated upon, especially important for handling loop tails or partial vector operations.