This is an archive of the discontinued LLVM Phabricator instance.

[LSV] Use Instruction*s rather than Value*s where possible.
ClosedPublic

Authored by jlebar on Jul 27 2016, 2:52 PM.

Details

Summary

Given the crash in D22878, this patch converts the load/store vectorizer
to use explicit Instruction*s wherever possible. This is an overall
simplification and should be an improvement in safety, as we have fewer
naked cast<>s, and now where we use Value*, we really mean something
different from Instruction*.

This patch also gets rid of some cast<>s around Value*s returned by
Builder. Given that Builder constant-folds everything, we can't assume
much about what we get out of it.

One downside of this patch is that we have to copy our chain before
calling propagateMetadata. But I don't think this is a big deal, as our
chains are very small (usually 2 or 4 elems).

Diff Detail

Repository
rL LLVM

Event Timeline

jlebar updated this revision to Diff 65809.Jul 27 2016, 2:52 PM
jlebar retitled this revision from to [LSV] Use Instruction*s rather than Value*s where possible..
jlebar updated this object.
jlebar added a reviewer: asbirlea.
jlebar added subscribers: arsenm, llvm-commits.
asbirlea edited edge metadata.Jul 27 2016, 3:33 PM

I had mixed feeling about some of the changes, but considering the overall removal of casts, this looks worth doing.

lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
846 ↗(On Diff #65809)

When is this not a store instruction? Does it affect in any way the decision to vectorize (it's kinda late in the flow..)?

973 ↗(On Diff #65809)

Same as for stores. When is this not a load and what does that mean? (consequences when used below? I honestly have no idea...)
Perhaps add a comment explaining this?

jlebar updated this revision to Diff 65828.Jul 27 2016, 4:05 PM
jlebar marked 2 inline comments as done.
jlebar edited edge metadata.

Remove spurrious checks.

lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
846 ↗(On Diff #65809)

Looking at the Builder code I don't think it can do that today, for a load or a store.

Normally I'd say I don't want to rely on the existing behavior -- having a load of a constant return a constant doesn't seem unreasonable -- but I'm sure that any attempt to change the behavior of Builder would break tons of other people too. So, we might as well depend on it too.

Changed.

jlebar marked an inline comment as done.Jul 27 2016, 4:05 PM
asbirlea accepted this revision.Jul 27 2016, 4:12 PM
asbirlea edited edge metadata.
asbirlea added inline comments.
lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
971 ↗(On Diff #65828)

Nit: move comment to the cast?

This revision is now accepted and ready to land.Jul 27 2016, 4:12 PM
jlebar marked an inline comment as done.Jul 27 2016, 4:13 PM
This revision was automatically updated to reflect the committed changes.