mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
[X86][SSE] Bitcast assertion in XFormVExtractWithShuffleIntoLoad
Minor patch to fix an issue in XFormVExtractWithShuffleIntoLoad where a load is unary shuffled, then bitcast (to a type with the same number of elements) before extracting an element. An undef was created for the second shuffle operand using the original (post-bitcasted) vector type instead of the pre-bitcasted type like the rest of the shuffle node - this was then causing an assertion on the different types later on inside SelectionDAG::getVectorShuffle. Differential Revision: http://reviews.llvm.org/D5917 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220592 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8699f5390b
commit
44efa200e2
@ -21776,7 +21776,7 @@ static SDValue PerformTruncateCombine(SDNode *N, SelectionDAG &DAG,
|
||||
/// XFormVExtractWithShuffleIntoLoad - Check if a vector extract from a target
|
||||
/// specific shuffle of a load can be folded into a single element load.
|
||||
/// Similar handling for VECTOR_SHUFFLE is performed by DAGCombiner, but
|
||||
/// shuffles have been customed lowered so we need to handle those here.
|
||||
/// shuffles have been custom lowered so we need to handle those here.
|
||||
static SDValue XFormVExtractWithShuffleIntoLoad(SDNode *N, SelectionDAG &DAG,
|
||||
TargetLowering::DAGCombinerInfo &DCI) {
|
||||
if (DCI.isBeforeLegalizeOps())
|
||||
@ -21788,18 +21788,20 @@ static SDValue XFormVExtractWithShuffleIntoLoad(SDNode *N, SelectionDAG &DAG,
|
||||
if (!isa<ConstantSDNode>(EltNo))
|
||||
return SDValue();
|
||||
|
||||
EVT VT = InVec.getValueType();
|
||||
EVT OriginalVT = InVec.getValueType();
|
||||
|
||||
if (InVec.getOpcode() == ISD::BITCAST) {
|
||||
// Don't duplicate a load with other uses.
|
||||
if (!InVec.hasOneUse())
|
||||
return SDValue();
|
||||
EVT BCVT = InVec.getOperand(0).getValueType();
|
||||
if (BCVT.getVectorNumElements() != VT.getVectorNumElements())
|
||||
if (BCVT.getVectorNumElements() != OriginalVT.getVectorNumElements())
|
||||
return SDValue();
|
||||
InVec = InVec.getOperand(0);
|
||||
}
|
||||
|
||||
EVT CurrentVT = InVec.getValueType();
|
||||
|
||||
if (!isTargetShuffle(InVec.getOpcode()))
|
||||
return SDValue();
|
||||
|
||||
@ -21809,12 +21811,12 @@ static SDValue XFormVExtractWithShuffleIntoLoad(SDNode *N, SelectionDAG &DAG,
|
||||
|
||||
SmallVector<int, 16> ShuffleMask;
|
||||
bool UnaryShuffle;
|
||||
if (!getTargetShuffleMask(InVec.getNode(), VT.getSimpleVT(), ShuffleMask,
|
||||
UnaryShuffle))
|
||||
if (!getTargetShuffleMask(InVec.getNode(), CurrentVT.getSimpleVT(),
|
||||
ShuffleMask, UnaryShuffle))
|
||||
return SDValue();
|
||||
|
||||
// Select the input vector, guarding against out of range extract vector.
|
||||
unsigned NumElems = VT.getVectorNumElements();
|
||||
unsigned NumElems = CurrentVT.getVectorNumElements();
|
||||
int Elt = cast<ConstantSDNode>(EltNo)->getZExtValue();
|
||||
int Idx = (Elt > (int)NumElems) ? -1 : ShuffleMask[Elt];
|
||||
SDValue LdNode = (Idx < (int)NumElems) ? InVec.getOperand(0)
|
||||
@ -21856,11 +21858,12 @@ static SDValue XFormVExtractWithShuffleIntoLoad(SDNode *N, SelectionDAG &DAG,
|
||||
SDLoc dl(N);
|
||||
|
||||
// Create shuffle node taking into account the case that its a unary shuffle
|
||||
SDValue Shuffle = (UnaryShuffle) ? DAG.getUNDEF(VT) : InVec.getOperand(1);
|
||||
Shuffle = DAG.getVectorShuffle(InVec.getValueType(), dl,
|
||||
SDValue Shuffle = (UnaryShuffle) ? DAG.getUNDEF(CurrentVT)
|
||||
: InVec.getOperand(1);
|
||||
Shuffle = DAG.getVectorShuffle(CurrentVT, dl,
|
||||
InVec.getOperand(0), Shuffle,
|
||||
&ShuffleMask[0]);
|
||||
Shuffle = DAG.getNode(ISD::BITCAST, dl, VT, Shuffle);
|
||||
Shuffle = DAG.getNode(ISD::BITCAST, dl, OriginalVT, Shuffle);
|
||||
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, N->getValueType(0), Shuffle,
|
||||
EltNo);
|
||||
}
|
||||
|
@ -46,3 +46,19 @@ bb:
|
||||
store double %.sroa.3.24.vec.extract, double* undef, align 8
|
||||
unreachable
|
||||
}
|
||||
|
||||
; Case where a load is unary shuffled, then bitcast (to a type with the same
|
||||
; number of elements) before extractelement.
|
||||
; This is testing for an assertion - the extraction was assuming that the undef
|
||||
; second shuffle operand was a post-bitcast type instead of a pre-bitcast type.
|
||||
define i64 @t4(<2 x double>* %a) {
|
||||
; CHECK-LABEL: t4:
|
||||
; CHECK: mov
|
||||
; CHECK: ret
|
||||
%b = load <2 x double>* %a, align 16
|
||||
%c = shufflevector <2 x double> %b, <2 x double> %b, <2 x i32> <i32 1, i32 0>
|
||||
%d = bitcast <2 x double> %c to <2 x i64>
|
||||
%e = extractelement <2 x i64> %d, i32 1
|
||||
ret i64 %e
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user