From 27b9ac2372e5340fe92196f47cb31ed72d367aa4 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 16 Feb 2018 21:36:29 +0000 Subject: [PATCH] [X86] In lowerVSELECTtoVectorShuffle, don't map undef select condition to undef in shuffle mask. Undef in select condition means we should pick the element from one side or the other. An undef in a shuffle mask means pick any element from either source or worse. I suspect by the time we get here most of the undefs in a constant vector have been removed by other things, but doing this for safety. llvm-svn: 325394 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 70b04376e1bd..89575fb3de2f 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -14745,9 +14745,12 @@ static SDValue lowerVSELECTtoVectorShuffle(SDValue Op, SmallVector Mask; for (int i = 0, Size = VT.getVectorNumElements(); i < Size; ++i) { SDValue CondElt = CondBV->getOperand(i); - Mask.push_back( - isa(CondElt) ? i + (isNullConstant(CondElt) ? Size : 0) - : -1); + int M = i; + // We can't map undef to undef here. They have different meanings. Treat + // as the same as zero. + if (CondElt.isUndef() || isNullConstant(CondElt)) + M += Size; + Mask.push_back(M); } return DAG.getVectorShuffle(VT, dl, LHS, RHS, Mask); }