<div dir="ltr"><div>A vector select with a constant vector condition operand:<br><br>define <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) {<br>  %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i32> %a, <4 x i32> %b<br>  ret <4 x i32> %sel<br>}<br><br><br>...is equivalent to a shufflevector:<br><br>define <4 x i32> @goo(<4 x i32> %a, <4 x i32> %b) {<br>  %shuf = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 6, i32 3><br>  ret <4 x i32> %shuf<br>}<br><br><br>For the goal of canonicalization in IR, which of these should we prefer? Some backend / lowering differences for AArch64 and PPC are noted in:<br><a href="https://llvm.org/bugs/show_bug.cgi?id=28530">https://llvm.org/bugs/show_bug.cgi?id=28530</a><br><a href="https://llvm.org/bugs/show_bug.cgi?id=28531">https://llvm.org/bugs/show_bug.cgi?id=28531</a><br><br></div>x86 converts either form optimally in all cases I've looked at.<br><div><br>This question first came up in D22114 ( <a href="https://reviews.llvm.org/D22114">https://reviews.llvm.org/D22114</a> ) and is extended in D23886 ( <a href="https://reviews.llvm.org/D23886">https://reviews.llvm.org/D23886</a> ) with a constant value example.<br><br></div></div>