mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
[X86] Fixes bug in build_vector v4x32 lowering
r222375 made some improvements to build_vector lowering of v4x32 and v4xf32 into an insertps, but it missed a case where: 1. A single extracted element is used twice. 2. The lower of the two non-zero indexes should be preserved, and the higher should be used for the dest mask. This caused a crash, since the source value for the insertps ends-up uninitialized. Differential Revision: http://reviews.llvm.org/D6377 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222635 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -5771,7 +5771,8 @@ static SDValue LowerBuildVectorv4x32(SDValue Op, SelectionDAG &DAG,
|
||||
// We only know how to deal with build_vector nodes where elements are either
|
||||
// zeroable or extract_vector_elt with constant index.
|
||||
SDValue FirstNonZero;
|
||||
for (int i=0; i < 4; ++i) {
|
||||
unsigned FirstNonZeroIdx;
|
||||
for (unsigned i=0; i < 4; ++i) {
|
||||
if (Zeroable[i])
|
||||
continue;
|
||||
SDValue Elt = Op->getOperand(i);
|
||||
@@ -5782,8 +5783,10 @@ static SDValue LowerBuildVectorv4x32(SDValue Op, SelectionDAG &DAG,
|
||||
MVT VT = Elt.getOperand(0).getSimpleValueType();
|
||||
if (!VT.is128BitVector())
|
||||
return SDValue();
|
||||
if (!FirstNonZero.getNode())
|
||||
if (!FirstNonZero.getNode()) {
|
||||
FirstNonZero = Elt;
|
||||
FirstNonZeroIdx = i;
|
||||
}
|
||||
}
|
||||
|
||||
assert(FirstNonZero.getNode() && "Unexpected build vector of all zeros!");
|
||||
@@ -5822,7 +5825,7 @@ static SDValue LowerBuildVectorv4x32(SDValue Op, SelectionDAG &DAG,
|
||||
return SDValue();
|
||||
|
||||
SDValue V2 = Elt.getOperand(0);
|
||||
if (Elt == FirstNonZero)
|
||||
if (Elt == FirstNonZero && EltIdx == FirstNonZeroIdx)
|
||||
V1 = SDValue();
|
||||
|
||||
bool CanFold = true;
|
||||
|
||||
Reference in New Issue
Block a user