1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

More DebugLoc propagation in LOAD etc. methods.

llvm-svn: 63451
This commit is contained in:
Bill Wendling 2009-01-30 23:27:35 +00:00
parent 7eb7de0393
commit 061530382c

View File

@ -4367,14 +4367,14 @@ SDValue DAGCombiner::visitFABS(SDNode *N) {
// fold (fabs c1) -> fabs(c1) // fold (fabs c1) -> fabs(c1)
if (N0CFP && VT != MVT::ppcf128) if (N0CFP && VT != MVT::ppcf128)
return DAG.getNode(ISD::FABS, VT, N0); return DAG.getNode(ISD::FABS, N->getDebugLoc(), VT, N0);
// fold (fabs (fabs x)) -> (fabs x) // fold (fabs (fabs x)) -> (fabs x)
if (N0.getOpcode() == ISD::FABS) if (N0.getOpcode() == ISD::FABS)
return N->getOperand(0); return N->getOperand(0);
// fold (fabs (fneg x)) -> (fabs x) // fold (fabs (fneg x)) -> (fabs x)
// fold (fabs (fcopysign x, y)) -> (fabs x) // fold (fabs (fcopysign x, y)) -> (fabs x)
if (N0.getOpcode() == ISD::FNEG || N0.getOpcode() == ISD::FCOPYSIGN) if (N0.getOpcode() == ISD::FNEG || N0.getOpcode() == ISD::FCOPYSIGN)
return DAG.getNode(ISD::FABS, VT, N0.getOperand(0)); return DAG.getNode(ISD::FABS, N->getDebugLoc(), VT, N0.getOperand(0));
// Transform fabs(bitconvert(x)) -> bitconvert(x&~sign) to avoid loading // Transform fabs(bitconvert(x)) -> bitconvert(x&~sign) to avoid loading
// constant pool values. // constant pool values.
@ -4384,10 +4384,11 @@ SDValue DAGCombiner::visitFABS(SDNode *N) {
SDValue Int = N0.getOperand(0); SDValue Int = N0.getOperand(0);
MVT IntVT = Int.getValueType(); MVT IntVT = Int.getValueType();
if (IntVT.isInteger() && !IntVT.isVector()) { if (IntVT.isInteger() && !IntVT.isVector()) {
Int = DAG.getNode(ISD::AND, IntVT, Int, Int = DAG.getNode(ISD::AND, DebugLoc::getUnknownLoc(), IntVT, Int,
DAG.getConstant(~IntVT.getIntegerVTSignBit(), IntVT)); DAG.getConstant(~IntVT.getIntegerVTSignBit(), IntVT));
AddToWorkList(Int.getNode()); AddToWorkList(Int.getNode());
return DAG.getNode(ISD::BIT_CONVERT, N->getValueType(0), Int); return DAG.getNode(ISD::BIT_CONVERT, N->getDebugLoc(),
N->getValueType(0), Int);
} }
} }
@ -4405,14 +4406,16 @@ SDValue DAGCombiner::visitBRCOND(SDNode *N) {
return Chain; return Chain;
// unconditional branch // unconditional branch
if (N1C && N1C->getAPIntValue() == 1) if (N1C && N1C->getAPIntValue() == 1)
return DAG.getNode(ISD::BR, MVT::Other, Chain, N2); return DAG.getNode(ISD::BR, N->getDebugLoc(), MVT::Other, Chain, N2);
// fold a brcond with a setcc condition into a BR_CC node if BR_CC is legal // fold a brcond with a setcc condition into a BR_CC node if BR_CC is legal
// on the target. // on the target.
if (N1.getOpcode() == ISD::SETCC && if (N1.getOpcode() == ISD::SETCC &&
TLI.isOperationLegalOrCustom(ISD::BR_CC, MVT::Other)) { TLI.isOperationLegalOrCustom(ISD::BR_CC, MVT::Other)) {
return DAG.getNode(ISD::BR_CC, MVT::Other, Chain, N1.getOperand(2), return DAG.getNode(ISD::BR_CC, N->getDebugLoc(), MVT::Other,
Chain, N1.getOperand(2),
N1.getOperand(0), N1.getOperand(1), N2); N1.getOperand(0), N1.getOperand(1), N2);
} }
return SDValue(); return SDValue();
} }
@ -4431,21 +4434,22 @@ SDValue DAGCombiner::visitBR_CC(SDNode *N) {
// fold br_cc true, dest -> br dest (unconditional branch) // fold br_cc true, dest -> br dest (unconditional branch)
if (SCCC && !SCCC->isNullValue()) if (SCCC && !SCCC->isNullValue())
return DAG.getNode(ISD::BR, MVT::Other, N->getOperand(0), return DAG.getNode(ISD::BR, N->getDebugLoc(), MVT::Other,
N->getOperand(4)); N->getOperand(0), N->getOperand(4));
// fold br_cc false, dest -> unconditional fall through // fold br_cc false, dest -> unconditional fall through
if (SCCC && SCCC->isNullValue()) if (SCCC && SCCC->isNullValue())
return N->getOperand(0); return N->getOperand(0);
// fold to a simpler setcc // fold to a simpler setcc
if (Simp.getNode() && Simp.getOpcode() == ISD::SETCC) if (Simp.getNode() && Simp.getOpcode() == ISD::SETCC)
return DAG.getNode(ISD::BR_CC, MVT::Other, N->getOperand(0), return DAG.getNode(ISD::BR_CC, N->getDebugLoc(), MVT::Other,
Simp.getOperand(2), Simp.getOperand(0), N->getOperand(0), Simp.getOperand(2),
Simp.getOperand(1), N->getOperand(4)); Simp.getOperand(0), Simp.getOperand(1),
N->getOperand(4));
return SDValue(); return SDValue();
} }
/// CombineToPreIndexedLoadStore - Try turning a load / store into a /// CombineToPreIndexedLoadStore - Try turning a load / store into a
/// pre-indexed load / store when the base pointer is an add or subtract /// pre-indexed load / store when the base pointer is an add or subtract
/// and it has other uses besides the load / store. After the /// and it has other uses besides the load / store. After the
@ -4476,8 +4480,9 @@ bool DAGCombiner::CombineToPreIndexedLoadStore(SDNode *N) {
return false; return false;
Ptr = ST->getBasePtr(); Ptr = ST->getBasePtr();
isLoad = false; isLoad = false;
} else } else {
return false; return false;
}
// If the pointer is not an add/sub, or if it doesn't have multiple uses, bail // If the pointer is not an add/sub, or if it doesn't have multiple uses, bail
// out. There is no reason to make this a preinc/predec. // out. There is no reason to make this a preinc/predec.
@ -4532,14 +4537,17 @@ bool DAGCombiner::CombineToPreIndexedLoadStore(SDNode *N) {
cast<StoreSDNode>(Use)->getBasePtr() == Ptr))) cast<StoreSDNode>(Use)->getBasePtr() == Ptr)))
RealUse = true; RealUse = true;
} }
if (!RealUse) if (!RealUse)
return false; return false;
SDValue Result; SDValue Result;
if (isLoad) if (isLoad)
Result = DAG.getIndexedLoad(SDValue(N,0), BasePtr, Offset, AM); Result = DAG.getIndexedLoad(SDValue(N,0), N->getDebugLoc(),
BasePtr, Offset, AM);
else else
Result = DAG.getIndexedStore(SDValue(N,0), BasePtr, Offset, AM); Result = DAG.getIndexedStore(SDValue(N,0), N->getDebugLoc(),
BasePtr, Offset, AM);
++PreIndexedNodes; ++PreIndexedNodes;
++NodesCombined; ++NodesCombined;
DOUT << "\nReplacing.4 "; DEBUG(N->dump(&DAG)); DOUT << "\nReplacing.4 "; DEBUG(N->dump(&DAG));
@ -4597,8 +4605,9 @@ bool DAGCombiner::CombineToPostIndexedLoadStore(SDNode *N) {
return false; return false;
Ptr = ST->getBasePtr(); Ptr = ST->getBasePtr();
isLoad = false; isLoad = false;
} else } else {
return false; return false;
}
if (Ptr.getNode()->hasOneUse()) if (Ptr.getNode()->hasOneUse())
return false; return false;
@ -4657,14 +4666,17 @@ bool DAGCombiner::CombineToPostIndexedLoadStore(SDNode *N) {
} }
} }
} }
if (TryNext) if (TryNext)
continue; continue;
// Check for #2 // Check for #2
if (!Op->isPredecessorOf(N) && !N->isPredecessorOf(Op)) { if (!Op->isPredecessorOf(N) && !N->isPredecessorOf(Op)) {
SDValue Result = isLoad SDValue Result = isLoad
? DAG.getIndexedLoad(SDValue(N,0), BasePtr, Offset, AM) ? DAG.getIndexedLoad(SDValue(N,0), N->getDebugLoc(),
: DAG.getIndexedStore(SDValue(N,0), BasePtr, Offset, AM); BasePtr, Offset, AM)
: DAG.getIndexedStore(SDValue(N,0), N->getDebugLoc(),
BasePtr, Offset, AM);
++PostIndexedNodes; ++PostIndexedNodes;
++NodesCombined; ++NodesCombined;
DOUT << "\nReplacing.5 "; DEBUG(N->dump(&DAG)); DOUT << "\nReplacing.5 "; DEBUG(N->dump(&DAG));
@ -4694,6 +4706,7 @@ bool DAGCombiner::CombineToPostIndexedLoadStore(SDNode *N) {
} }
} }
} }
return false; return false;
} }
@ -4749,13 +4762,13 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
if (!Fast && LD->isUnindexed()) { if (!Fast && LD->isUnindexed()) {
if (unsigned Align = InferAlignment(Ptr, DAG)) { if (unsigned Align = InferAlignment(Ptr, DAG)) {
if (Align > LD->getAlignment()) if (Align > LD->getAlignment())
return DAG.getExtLoad(LD->getExtensionType(), LD->getValueType(0), return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(),
LD->getValueType(0),
Chain, Ptr, LD->getSrcValue(), Chain, Ptr, LD->getSrcValue(),
LD->getSrcValueOffset(), LD->getMemoryVT(), LD->getSrcValueOffset(), LD->getMemoryVT(),
LD->isVolatile(), Align); LD->isVolatile(), Align);
} }
} }
// If load is not volatile and there are no uses of the loaded value (and // If load is not volatile and there are no uses of the loaded value (and
// the updated indexed value in case of indexed loads), change uses of the // the updated indexed value in case of indexed loads), change uses of the
@ -4775,10 +4788,12 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
DOUT << "\n"; DOUT << "\n";
WorkListRemover DeadNodes(*this); WorkListRemover DeadNodes(*this);
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1), Chain, &DeadNodes); DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1), Chain, &DeadNodes);
if (N->use_empty()) { if (N->use_empty()) {
removeFromWorkList(N); removeFromWorkList(N);
DAG.DeleteNode(N); DAG.DeleteNode(N);
} }
return SDValue(N, 0); // Return N so it doesn't get rechecked! return SDValue(N, 0); // Return N so it doesn't get rechecked!
} }
} else { } else {
@ -4792,7 +4807,8 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
WorkListRemover DeadNodes(*this); WorkListRemover DeadNodes(*this);
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 0), Undef, &DeadNodes); DAG.ReplaceAllUsesOfValueWith(SDValue(N, 0), Undef, &DeadNodes);
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1), DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1),
DAG.getNode(ISD::UNDEF, N->getValueType(1)), DAG.getNode(ISD::UNDEF, DebugLoc::getUnknownLoc(),
N->getValueType(1)),
&DeadNodes); &DeadNodes);
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 2), Chain, &DeadNodes); DAG.ReplaceAllUsesOfValueWith(SDValue(N, 2), Chain, &DeadNodes);
removeFromWorkList(N); removeFromWorkList(N);
@ -4826,11 +4842,12 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
// Replace the chain to void dependency. // Replace the chain to void dependency.
if (LD->getExtensionType() == ISD::NON_EXTLOAD) { if (LD->getExtensionType() == ISD::NON_EXTLOAD) {
ReplLoad = DAG.getLoad(N->getValueType(0), BetterChain, Ptr, ReplLoad = DAG.getLoad(N->getValueType(0), LD->getDebugLoc(),
BetterChain, Ptr,
LD->getSrcValue(), LD->getSrcValueOffset(), LD->getSrcValue(), LD->getSrcValueOffset(),
LD->isVolatile(), LD->getAlignment()); LD->isVolatile(), LD->getAlignment());
} else { } else {
ReplLoad = DAG.getExtLoad(LD->getExtensionType(), ReplLoad = DAG.getExtLoad(LD->getExtensionType(), LD->getDebugLoc(),
LD->getValueType(0), LD->getValueType(0),
BetterChain, Ptr, LD->getSrcValue(), BetterChain, Ptr, LD->getSrcValue(),
LD->getSrcValueOffset(), LD->getSrcValueOffset(),
@ -4840,8 +4857,8 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
} }
// Create token factor to keep old chain connected. // Create token factor to keep old chain connected.
SDValue Token = DAG.getNode(ISD::TokenFactor, MVT::Other, SDValue Token = DAG.getNode(ISD::TokenFactor, N->getDebugLoc(),
Chain, ReplLoad.getValue(1)); MVT::Other, Chain, ReplLoad.getValue(1));
// Replace uses with load result and token factor. Don't add users // Replace uses with load result and token factor. Don't add users
// to work list. // to work list.
@ -4856,7 +4873,6 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
return SDValue(); return SDValue();
} }
SDValue DAGCombiner::visitSTORE(SDNode *N) { SDValue DAGCombiner::visitSTORE(SDNode *N) {
StoreSDNode *ST = cast<StoreSDNode>(N); StoreSDNode *ST = cast<StoreSDNode>(N);
SDValue Chain = ST->getChain(); SDValue Chain = ST->getChain();