mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-24 09:29:42 +00:00
Fixed a couple of optimization with EXTRACT_VECTOR_ELT that assumes the result
type is the same as the element type of the vector. EXTRACT_VECTOR_ELT can be used to extended the width of an integer type. This fixes a bug for Generic/vector-casts.ll on a ppc750. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94990 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a00ef1122c
commit
c6654ec498
@ -5403,12 +5403,19 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
|
|||||||
SDValue InVec = N->getOperand(0);
|
SDValue InVec = N->getOperand(0);
|
||||||
|
|
||||||
if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR) {
|
if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR) {
|
||||||
// If the operand is wider than the vector element type then it is implicitly
|
// Check if the result type doesn't match the inserted element type. A
|
||||||
// truncated. Make that explicit here.
|
// SCALAR_TO_VECTOR may truncate the inserted element and the
|
||||||
|
// EXTRACT_VECTOR_ELT may widen the extracted vector.
|
||||||
EVT EltVT = InVec.getValueType().getVectorElementType();
|
EVT EltVT = InVec.getValueType().getVectorElementType();
|
||||||
SDValue InOp = InVec.getOperand(0);
|
SDValue InOp = InVec.getOperand(0);
|
||||||
if (InOp.getValueType() != EltVT)
|
EVT NVT = N->getValueType(0);
|
||||||
return DAG.getNode(ISD::TRUNCATE, InVec.getDebugLoc(), EltVT, InOp);
|
if (InOp.getValueType() != NVT) {
|
||||||
|
assert(InOp.getValueType().isInteger() && NVT.isInteger());
|
||||||
|
if (NVT.getSizeInBits() > InOp.getValueType().getSizeInBits())
|
||||||
|
return DAG.getNode(ISD::SIGN_EXTEND, InVec.getDebugLoc(), NVT, InOp);
|
||||||
|
else
|
||||||
|
return DAG.getNode(ISD::TRUNCATE, InVec.getDebugLoc(), NVT, InOp);
|
||||||
|
}
|
||||||
return InOp;
|
return InOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2765,7 +2765,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL, EVT VT,
|
|||||||
// operations are lowered to scalars.
|
// operations are lowered to scalars.
|
||||||
if (N1.getOpcode() == ISD::INSERT_VECTOR_ELT) {
|
if (N1.getOpcode() == ISD::INSERT_VECTOR_ELT) {
|
||||||
// If the indices are the same, return the inserted element.
|
// If the indices are the same, return the inserted element.
|
||||||
if (N1.getOperand(2) == N2)
|
if (N1.getOperand(2) == N2 && VT == N1.getOperand(1).getValueType())
|
||||||
return N1.getOperand(1);
|
return N1.getOperand(1);
|
||||||
// If the indices are known different, extract the element from
|
// If the indices are known different, extract the element from
|
||||||
// the original vector.
|
// the original vector.
|
||||||
|
Loading…
Reference in New Issue
Block a user