mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-28 15:33:16 +00:00
[X86] Fix non-determinism in LowerVectorAllZeroTest
This can be observed with the old testcase of CodeGen/X86/pr12312.ll: 47c47 < vorps %ymm0, %ymm1, %ymm0 --- > vorps %ymm1, %ymm0, %ymm0 97c97 < vorps %ymm1, %ymm0, %ymm0 --- > vorps %ymm0, %ymm1, %ymm0 The vector VecIns is populated with all the values from VecInMap. This is done while iterating VecInMap. VecInMap uses a hash of pointer values so the resulting order can vary depending on the memory layout. The fix is to populate the vector VecIns earlier as VecInMap is populated. This is done in DAG traversal order. Fixes <rdar://problem/16398806> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204623 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8ce101ed10
commit
a1b54dd1ff
@ -9454,6 +9454,7 @@ static SDValue LowerVectorAllZeroTest(SDValue Op, const X86Subtarget *Subtarget,
|
||||
|
||||
SmallVector<SDValue, 8> Opnds;
|
||||
DenseMap<SDValue, unsigned> VecInMap;
|
||||
SmallVector<SDValue, 8> VecIns;
|
||||
EVT VT = MVT::Other;
|
||||
|
||||
// Recognize a special case where a vector is casted into wide integer to
|
||||
@ -9493,6 +9494,7 @@ static SDValue LowerVectorAllZeroTest(SDValue Op, const X86Subtarget *Subtarget,
|
||||
VT != VecInMap.begin()->first.getValueType())
|
||||
return SDValue();
|
||||
M = VecInMap.insert(std::make_pair(ExtractedFromVec, 0)).first;
|
||||
VecIns.push_back(ExtractedFromVec);
|
||||
}
|
||||
M->second |= 1U << cast<ConstantSDNode>(Idx)->getZExtValue();
|
||||
}
|
||||
@ -9501,14 +9503,12 @@ static SDValue LowerVectorAllZeroTest(SDValue Op, const X86Subtarget *Subtarget,
|
||||
"Not extracted from 128-/256-bit vector.");
|
||||
|
||||
unsigned FullMask = (1U << VT.getVectorNumElements()) - 1U;
|
||||
SmallVector<SDValue, 8> VecIns;
|
||||
|
||||
for (DenseMap<SDValue, unsigned>::const_iterator
|
||||
I = VecInMap.begin(), E = VecInMap.end(); I != E; ++I) {
|
||||
// Quit if not all elements are used.
|
||||
if (I->second != FullMask)
|
||||
return SDValue();
|
||||
VecIns.push_back(I->first);
|
||||
}
|
||||
|
||||
EVT TestVT = VT.is128BitVector() ? MVT::v2i64 : MVT::v4i64;
|
||||
|
Loading…
Reference in New Issue
Block a user