This is an archive of the discontinued LLVM Phabricator instance.

[ConstantFold][SVE] Fix constant folding for shufflevector.
ClosedPublic

Authored by efriedma on Dec 6 2019, 12:59 PM.

Details

Summary

Don't try to fold away shuffles which can't be folded. Fix creation of shufflevector constant expressions.

Diff Detail

Event Timeline

efriedma created this revision.Dec 6 2019, 12:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2019, 12:59 PM
spatel accepted this revision.Dec 8 2019, 6:35 AM

Similar to D70985 - LGTM.

I haven't looked at scalable vectors very much though, so I'm not sure if there are still problems for any other opcodes. Eg, ConstantFoldSelectInstruction can iterate based on number of elements.

llvm/test/Analysis/ConstantFolding/shufflevector.ll
5

Can reduce this to a single shuffle and still get the same crash?

define <vscale x 4 x i32> @shufflevector_scalable_constant() {
  %r = shufflevector <vscale x 4 x i32> undef, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
  ret <vscale x 4 x i32> %r
}
This revision is now accepted and ready to land.Dec 8 2019, 6:35 AM
efriedma marked an inline comment as done.Dec 9 2019, 2:54 PM

I haven't looked at scalable vectors very much though, so I'm not sure if there are still problems for any other opcodes.

There are; Huihui is going to look into this. This particular case happened to be blocking some other work I'm doing.

llvm/test/Analysis/ConstantFolding/shufflevector.ll
5

We'll probably fold that to undef at some point.

This revision was automatically updated to reflect the committed changes.