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.
Details
Diff Detail
- Build Status
Buildable 571 Build 571: arc lint + arc unit
Event Timeline
I assume the motivation is that we don't want to run adce after the vectorizer, and "regular" dce doesn't catch this because of loop-carried dependencies?
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.
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4241 | Perhaps replace the double-negation with "... if all its users except the induction variable are dead"? | |
4246 | 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? |
LGTM with a nit about naming.
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4243 | Ind/Induction combined with the two "autos" is confusing. Maybe make the type of Ind explicit (or call it IndPhi?)? |
lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
4243 | I'll make the type explicit. Thanks Michael! |
Perhaps replace the double-negation with "... if all its users except the induction variable are dead"?