Open rotateright opened 8 years ago
Thanks, Ehsan.
We may want to adapt the code in InstCombineVectorOps.cpp -> isShuffleEquivalentToSelect() for general use in the DAG.
x86 has a more specific shuffle-to-select matching blob of code in its lowerVectorShuffleAsBlend() that might also be worth copying/refactoring.
(In reply to comment #0 the IR.
We generate 'xxsel' and 'vperm' for a target with VSX. Is one better than the other?
vperm is generated for now canonical form (shuffle vector). Xxsel is preferrable as it has access to any of VSX register. That is a superset of VMX registers that vperm has access to.
The patch for canonicalization of vector select with constant condition to shuffle is here: https://reviews.llvm.org/D24279
Latest trunk behaviour - https://godbolt.org/z/8PE46h888. Function foo have vsel and goo have vperm instruction.
Extended Description
$ cat shufsel.ll define <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) { %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i32> %a,
<4 x i32> %b ret <4 x i32> %sel } define <4 x i32> @goo(<4 x i32> %a, <4 x i32> %b) { %shuf = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32>