[PATCH] D25631: [LV] Avoid emitting trivially dead instructions

Matthew Simpson via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 07:19:18 PDT 2016

mssimpso added inline comments.

Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:4241
+  // induction variables map. An original update instruction will be dead if it
+  // has no non-dead users other than the induction variable.
+  for (auto &Induction : *Legal->getInductionVars()) {
gilr wrote:
> Perhaps replace the double-negation with "... if all its users except the induction variable are dead"?
That's much better. Thanks!

Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:4246
+    if (all_of(IndUpdate->users(),
+               [&](User *U) -> bool { return U == Ind || U == Cmp; }))
+      DeadInstructions.insert(IndUpdate);
gilr wrote:
> 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?
Yes, nice catch! I'll update the patch.


More information about the llvm-commits mailing list