Propagate debug loc info for UDIV.

llvm-svn: 63373
This commit is contained in:
Bill Wendling 2009-01-30 02:55:25 +00:00
parent 5b663e7b53
commit aff3e03765
1 changed files with 7 additions and 6 deletions

View File

@ -1463,7 +1463,7 @@ SDValue DAGCombiner::visitUDIV(SDNode *N) {
return DAG.FoldConstantArithmetic(ISD::UDIV, VT, N0C, N1C); return DAG.FoldConstantArithmetic(ISD::UDIV, VT, N0C, N1C);
// fold (udiv x, (1 << c)) -> x >>u c // fold (udiv x, (1 << c)) -> x >>u c
if (N1C && N1C->getAPIntValue().isPowerOf2()) if (N1C && N1C->getAPIntValue().isPowerOf2())
return DAG.getNode(ISD::SRL, VT, N0, return DAG.getNode(ISD::SRL, N->getDebugLoc(), VT, N0,
DAG.getConstant(N1C->getAPIntValue().logBase2(), DAG.getConstant(N1C->getAPIntValue().logBase2(),
TLI.getShiftAmountTy())); TLI.getShiftAmountTy()));
// fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) iff c is power of 2 // fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) iff c is power of 2
@ -1471,12 +1471,13 @@ SDValue DAGCombiner::visitUDIV(SDNode *N) {
if (ConstantSDNode *SHC = dyn_cast<ConstantSDNode>(N1.getOperand(0))) { if (ConstantSDNode *SHC = dyn_cast<ConstantSDNode>(N1.getOperand(0))) {
if (SHC->getAPIntValue().isPowerOf2()) { if (SHC->getAPIntValue().isPowerOf2()) {
MVT ADDVT = N1.getOperand(1).getValueType(); MVT ADDVT = N1.getOperand(1).getValueType();
SDValue Add = DAG.getNode(ISD::ADD, ADDVT, N1.getOperand(1), SDValue Add = DAG.getNode(ISD::ADD, N->getDebugLoc(), ADDVT,
DAG.getConstant(SHC->getAPIntValue() N1.getOperand(1),
.logBase2(), DAG.getConstant(SHC->getAPIntValue()
ADDVT)); .logBase2(),
ADDVT));
AddToWorkList(Add.getNode()); AddToWorkList(Add.getNode());
return DAG.getNode(ISD::SRL, VT, N0, Add); return DAG.getNode(ISD::SRL, N->getDebugLoc(), VT, N0, Add);
} }
} }
} }