[DAG] combineShuffleOfSplatVal - fold shuffle(splat,undef) -> splat, iff the splat...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 7 Jun 2022 15:42:15 +0000 (16:42 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 7 Jun 2022 15:42:24 +0000 (16:42 +0100)
commita083f3caa1356ceaec2c250850928c01008f5f58
treeedef5b53e085b15c881257e409627caeface2bb2
parent7daa9a9b40a22c8ebac529f2fe7772191f2cea5a
[DAG] combineShuffleOfSplatVal - fold shuffle(splat,undef) -> splat, iff the splat contains no UNDEF elements

As noticed on D127115 - we were missing this fold, instead just having the shuffle(shuffle(x,undef,splatmask),undef) fold. We should be able to merge these into one using SelectionDAG::isSplatValue, but we'll need to match the shuffle's undef handling first.

This also exposed an issue in SelectionDAG::isSplatValue which was incorrectly propagating the undef mask across a bitcast (it was trying to just bail with a APInt::isSubsetOf if it found any undefs but that was actually the wrong way around so didn't fire for partial undef cases).
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/X86/vector-fshl-rot-256.ll
llvm/test/CodeGen/X86/vector-fshr-rot-256.ll