mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Fix a crash in the dag combiner caused by ConstantFoldBIT_CONVERTofBUILD_VECTOR calling itself
recursively and returning a SCALAR_TO_VECTOR node, but assuming the input was always a BUILD_VECTOR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109519 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
57cb4f8be1
commit
e0efc216eb
@ -4489,6 +4489,16 @@ ConstantFoldBIT_CONVERTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
|
||||
// If this is a conversion of N elements of one type to N elements of another
|
||||
// type, convert each element. This handles FP<->INT cases.
|
||||
if (SrcBitSize == DstBitSize) {
|
||||
EVT VT = EVT::getVectorVT(*DAG.getContext(), DstEltVT,
|
||||
BV->getValueType(0).getVectorNumElements());
|
||||
|
||||
// Due to the FP element handling below calling this routine recursively,
|
||||
// we can end up with a scalar-to-vector node here.
|
||||
if (BV->getOpcode() == ISD::SCALAR_TO_VECTOR)
|
||||
return DAG.getNode(ISD::SCALAR_TO_VECTOR, BV->getDebugLoc(), VT,
|
||||
DAG.getNode(ISD::BIT_CONVERT, BV->getDebugLoc(),
|
||||
DstEltVT, BV->getOperand(0)));
|
||||
|
||||
SmallVector<SDValue, 8> Ops;
|
||||
for (unsigned i = 0, e = BV->getNumOperands(); i != e; ++i) {
|
||||
SDValue Op = BV->getOperand(i);
|
||||
@ -4500,8 +4510,6 @@ ConstantFoldBIT_CONVERTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
|
||||
DstEltVT, Op));
|
||||
AddToWorkList(Ops.back().getNode());
|
||||
}
|
||||
EVT VT = EVT::getVectorVT(*DAG.getContext(), DstEltVT,
|
||||
BV->getValueType(0).getVectorNumElements());
|
||||
return DAG.getNode(ISD::BUILD_VECTOR, BV->getDebugLoc(), VT,
|
||||
&Ops[0], Ops.size());
|
||||
}
|
||||
|
6
test/CodeGen/Generic/2010-07-27-DAGCombineCrash.ll
Normal file
6
test/CodeGen/Generic/2010-07-27-DAGCombineCrash.ll
Normal file
@ -0,0 +1,6 @@
|
||||
; RUN: llc < %s
|
||||
|
||||
define float @test1()
|
||||
{
|
||||
ret float extractelement (<2 x float> bitcast (<1 x double> <double 0x3f800000> to <2 x float>), i32 1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user