Fix for PR4235: to build a floating-point value from integer parts,

build an integer and cast that to a float.  This fixes a crash 
caused by trying to split an f32 into two f16's.

This changes the behavior in test/CodeGen/XCore/fneg.ll because that 
testcase now triggers a DAGCombine which converts the fneg into an integer
operation.  If someone is interested, it's probably possible to tweak 
the test to generate an actual fneg.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72162 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman 2009-05-20 06:02:09 +00:00
parent c7d167d62f
commit 2ac8b324eb
3 changed files with 31 additions and 6 deletions

View File

@ -426,7 +426,7 @@ static SDValue getCopyFromParts(SelectionDAG &DAG, DebugLoc dl,
if (NumParts > 1) {
// Assemble the value from multiple parts.
if (!ValueVT.isVector()) {
if (!ValueVT.isVector() && ValueVT.isInteger()) {
unsigned PartBits = PartVT.getSizeInBits();
unsigned ValueBits = ValueVT.getSizeInBits();
@ -438,9 +438,7 @@ static SDValue getCopyFromParts(SelectionDAG &DAG, DebugLoc dl,
ValueVT : MVT::getIntegerVT(RoundBits);
SDValue Lo, Hi;
MVT HalfVT = ValueVT.isInteger() ?
MVT::getIntegerVT(RoundBits/2) :
MVT::getFloatingPointVT(RoundBits/2);
MVT HalfVT = MVT::getIntegerVT(RoundBits/2);
if (RoundParts > 2) {
Lo = getCopyFromParts(DAG, dl, Parts, RoundParts/2, PartVT, HalfVT);
@ -473,7 +471,7 @@ static SDValue getCopyFromParts(SelectionDAG &DAG, DebugLoc dl,
Lo = DAG.getNode(ISD::ZERO_EXTEND, dl, TotalVT, Lo);
Val = DAG.getNode(ISD::OR, dl, TotalVT, Lo, Hi);
}
} else {
} else if (ValueVT.isVector()) {
// Handle a multi-element vector.
MVT IntermediateVT, RegisterVT;
unsigned NumIntermediates;
@ -510,6 +508,22 @@ static SDValue getCopyFromParts(SelectionDAG &DAG, DebugLoc dl,
Val = DAG.getNode(IntermediateVT.isVector() ?
ISD::CONCAT_VECTORS : ISD::BUILD_VECTOR, dl,
ValueVT, &Ops[0], NumIntermediates);
} else if (PartVT.isFloatingPoint()) {
// FP split into multiple FP parts (for ppcf128)
assert(ValueVT == MVT(MVT::ppcf128) && PartVT == MVT(MVT::f64) &&
"Unexpected split");
SDValue Lo, Hi;
Lo = DAG.getNode(ISD::BIT_CONVERT, dl, MVT(MVT::f64), Parts[0]);
Hi = DAG.getNode(ISD::BIT_CONVERT, dl, MVT(MVT::f64), Parts[1]);
if (TLI.isBigEndian())
std::swap(Lo, Hi);
Val = DAG.getNode(ISD::BUILD_PAIR, dl, ValueVT, Lo, Hi);
} else {
// FP split into integer parts (soft fp)
assert(ValueVT.isFloatingPoint() && PartVT.isInteger() &&
!PartVT.isVector() && "Unexpected split");
MVT IntVT = MVT::getIntegerVT(ValueVT.getSizeInBits());
Val = getCopyFromParts(DAG, dl, Parts, NumParts, PartVT, IntVT);
}
}

View File

@ -0,0 +1,11 @@
; RUN: llvm-as < %s | llc -march=msp430
define i16 @test(double %d) nounwind {
entry:
%add = add double %d, 1.000000e+00
%call = tail call i16 @funct(double %add) nounwind
ret i16 %call
}
declare i16 @funct(double)

View File

@ -1,5 +1,5 @@
; RUN: llvm-as < %s | llc -march=xcore > %t1.s
; RUN: grep "bl __subdf3" %t1.s | count 1
; RUN: grep "xor" %t1.s | count 1
define i1 @test(double %F) nounwind {
entry:
%0 = sub double -0.000000e+00, %F