Some instructions from the original loop, when vectorized, can become trivially dead. This happens because of the way we structure the new loop. For example, we create new induction variables and induction variable "steps" in the new loop. Thus, when we go to vectorize the original induction variable update, it may no longer be needed due to the instructions we've already created. This patch prevents us from creating these redundant instructions. This reduces code size before simplification and allows greater flexibility in code generation since we have fewer unnecessary instruction uses.
No, this is mostly motivated by the sinking patch I submitted. These trivially dead instructions can create uses of scalar instructions that can potentially be sunk into predicated blocks. They prevent sinking because if we were to move the scalars, their definitions would no longer dominate the uses, even though the uses should later be deleted.
|4241 ↗||(On Diff #74727)|
Perhaps replace the double-negation with "... if all its users except the induction variable are dead"?
|4246 ↗||(On Diff #74727)|
The "|| U == Cmp" test seems to kill the update whether or not Cmp is dead. Per the above comment I think you meant here "|| DeadInstructions.count(U)", right?