[PATCH] D90418: [debuginfo] Vectorizing a loop doesn't terminate all vectorized variable locations

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 05:43:21 PDT 2021


jmorse added a comment.

Looking at the output of the test, it looks like the dbg.value(undef) is in the scalar tail of the loop, rather than vector.body, right? This is slightly cross purposes to what we want, I think: the induction variable value is unavailable during the vectorized portion of the loop and should be undef, but the scalar part isn't optimised, and so the value is still available.

IMO: it'd be sufficient to collect debug users of the induction variable and add new undefs at the entry to the vectorized loop.

(I'm basing this on e6eaacbf0bd <https://reviews.llvm.org/rGe6eaacbf0bd0c76a4fbfbd30c6159f57a89b3480> , sorry if my observations are because LoopVectorize has changed a lot over the months I've been ignoring your patch ._. )



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:3705-3706
 
+  // If there is an old induction variable we want it to have a meaningful value
+  // during the vector operations.
+  if (PHINode *OldInduction = Legal->getPrimaryInduction()) {
----------------
Could I suggest switching "variable" to "debug variable" here -- it makes it clearer that we're dealing with debug-info instead of some functional portion of the vectorised loop.


================
Comment at: llvm/test/Transforms/LoopVectorize/pr39018.ll:2-3
+;; PR39018
+;; Ensure that the loop vectorizer updates the debuginfo
+;; for the source induction variable.
+
----------------
Nit, "updates" is a bit like a commit message saying "updates": could you elaborate on what's supposed to happen, i.e.:
 * The loop gets vectorised,
 * Earlier variable locations should be terminated with an undef.
It'll help future readers work out what's going on.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90418/new/

https://reviews.llvm.org/D90418



More information about the llvm-commits mailing list