This is an archive of the discontinued LLVM Phabricator instance.

[X86][AVX] Ensure broadcast loads respect dependencies
ClosedPublic

Authored by RKSimon on Sep 28 2016, 12:28 PM.

Details

Summary

To allow broadcast loads of a non-zero'th vector element, lowerVectorShuffleAsBroadcast can replace a load with a new load with an adjusted address, but unfortunately we weren't ensuring that the new load respected the same dependencies.

This patch adds a TokenFactor and updates all dependencies of the old load to reference the new load instead.

Bug found during internal testing.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 72877.Sep 28 2016, 12:28 PM
RKSimon retitled this revision from to [X86][AVX] Ensure broadcast loads respect dependencies.
RKSimon updated this object.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
mkuper edited edge metadata.Oct 2 2016, 1:15 AM

Yikes.

Thanks, Simon!
This LGTM, although maybe it can be simpler. If you think this is better as is, feel free to commit.

lib/Target/X86/X86ISelLowering.cpp
8684 ↗(On Diff #72877)

Why do we need the TokenFactor? The load is only used in the shuffle, right? So why can't we just replace Ld with V completely?
Or do you prefer not to trust the load being DCE'd?

mkuper accepted this revision.Oct 2 2016, 1:15 AM
mkuper edited edge metadata.
This revision is now accepted and ready to land.Oct 2 2016, 1:15 AM

Thanks Michael.

lib/Target/X86/X86ISelLowering.cpp
8684 ↗(On Diff #72877)

Yes, I don't trust the load being dealt with correctly - the problems I had with subvector broadcast all revolved around those cases. I've been wondering whether it'd be cleaner to split the broadcast op into register and memory intrinsic ops to avoid this but for now we just have (ugly) fallback cases as tablegen patterns.

This revision was automatically updated to reflect the committed changes.