This is an archive of the discontinued LLVM Phabricator instance.

[mips][msa] Fix vector insertions where the index is variable
ClosedPublic

Authored by dsanders on Apr 29 2014, 6:03 AM.

Details

Summary

This isn't supported directly so we rotate the vector by the desired number of
elements, insert to element zero, then rotate back.

The i64 case generates rather poor code on MIPS32. There is an obvious
optimisation to be made in future (do both insert.w's inside a shared
rotate/unrotate sequence) but for now it's sufficient to select valid code
instead of aborting.

Depends on D3536

Diff Detail

Event Timeline

dsanders updated this revision to Diff 8914.Apr 29 2014, 6:03 AM
dsanders retitled this revision from to [mips][msa] Fix vector insertions where the index is variable.
dsanders updated this object.
dsanders edited the test plan for this revision. (Show Details)
dsanders added a reviewer: matheusalmeida.
matheusalmeida accepted this revision.Apr 30 2014, 2:54 AM
matheusalmeida edited edge metadata.

This looks good to me but take it with a grain of salt. The reason for this is that I'm not familiar with some methods used here (createVirtualReg...) and as you know I can't spend too much time doing these reviews.
Out of curiosity: Do you know if GCC uses the same instruction sequence as the one implemented here ?

lib/Target/Mips/MipsSEISelLowering.cpp
2964

This might be a dumb question but why MSA128WRegClass ? Would MSA128DRegClass also be OK ?

This revision is now accepted and ready to land.Apr 30 2014, 2:54 AM

Out of curiosity: Do you know if GCC uses the same instruction sequence as the one implemented here ?

GCC doesn't generate inserts/copies of any kind at the moment. It's doing insertions with a store vector + store element + load vector sequence.

lib/Target/Mips/MipsSEISelLowering.cpp
2964

That's a bug, it should be using the correct class for the type. I'll fix this.

2982

Same bug

2988

One more.

What about the uses of GPR32RegClass ? INSERT_D_VIDX_PSEUDO_DESC uses a GPR64RegClass.

What about the uses of GPR32RegClass ? INSERT_D_VIDX_PSEUDO_DESC uses a GPR64RegClass.

I'll fix that too but I'll base it on isGP64bit() rather than just when insert.d needs emitting. I'll leave it emitting the 32-bit negation though. The slide instructions will only look at the bottom four bits anyway.

It's worth mentioning that there's no testcase for the insert.d path. This can be added when MSA64 tests are generally added.

dsanders closed this revision.Apr 30 2014, 5:16 AM