Fix virtual PHI operand updates after loop header rewrite.
Vectorizer correctly updates virtual operands on loop exit edges after header rewrites.
The GCC vectorizer’s loop header rewrite pass (vect_set_loop_condition_partial_vectors) now correctly handles virtual operands on the loop’s exit edge. This fix ensures that any virtual operands live across the loop exit are properly updated after the header rewrite, preventing incorrect code generation, particularly in scenarios involving early break statements.
In Details
The vect_set_loop_condition_partial_vectors pass, which runs after early break movement, rewrites the loop header. This can introduce new virtual operands or modify existing ones on the loop exit edge. The get_live_virtual_operand_on_edge function was moved and adapted to update these virtual operands correctly, resolving issues with PR126778.
- Vectorizer
- A compiler component that transforms loops and scalar code into vector instructions for parallel execution on suitable hardware.
- Virtual operand
- An intermediate representation of a value in the compiler that may not directly correspond to a machine register or memory location, used during optimization passes.
- PHI node
- A special construct in Static Single Assignment (SSA) form that represents a value which may come from multiple control flow paths.
- Loop header rewrite
- A compiler optimization technique that restructures the entry point of a loop to facilitate other optimizations or vectorization.