diff options
author | Nate Begeman <natebegeman@mac.com> | 2005-10-20 17:45:03 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2005-10-20 17:45:03 +0000 |
commit | 7efe53d90b5896d8969a596d9dc08a272f752750 (patch) | |
tree | 0832ae1cb3bd70a2a594b9c4596cff33845a4aea /llvm/lib/CodeGen | |
parent | a6efeb01f96e17aba2f41c351635421ce00873e1 (diff) | |
download | bcm5719-llvm-7efe53d90b5896d8969a596d9dc08a272f752750.tar.gz bcm5719-llvm-7efe53d90b5896d8969a596d9dc08a272f752750.zip |
Fix a couple bugs in the const div stuff where we'd generate MULHS/MULHU
for types that aren't legal, and fail a divisor is less than zero
comparison, which would cause us to drop a subtract.
llvm-svn: 23846
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index eb0b88df98a..cf6106dbb33 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -790,7 +790,8 @@ SDOperand DAGCombiner::visitSDIV(SDNode *N) { // detect that too. if (N1C && !isPowerOf2_64(N1C->getSignExtended()) && (N1C->getSignExtended() < -1 || N1C->getSignExtended() > 1) && - TLI.isOperationLegal(ISD::MULHS, VT) && TLI.isIntDivExpensive()) { + TLI.isOperationLegal(ISD::MULHS, VT) && TLI.isTypeLegal(VT) && + TLI.isIntDivExpensive()) { return BuildSDIV(N); } return SDOperand(); @@ -814,7 +815,7 @@ SDOperand DAGCombiner::visitUDIV(SDNode *N) { TLI.getShiftAmountTy())); // fold (udiv x, c) -> alternate if (N1C && N1C->getValue() && TLI.isOperationLegal(ISD::MULHU, VT) && - TLI.isIntDivExpensive()) + TLI.isTypeLegal(VT) && TLI.isIntDivExpensive()) return BuildUDIV(N); return SDOperand(); } @@ -2555,7 +2556,7 @@ SDOperand DAGCombiner::BuildSDIV(SDNode *N) { assert((VT == MVT::i32 || VT == MVT::i64) && "BuildSDIV only operates on i32 or i64!"); - int64_t d = cast<ConstantSDNode>(N->getOperand(1))->getValue(); + int64_t d = cast<ConstantSDNode>(N->getOperand(1))->getSignExtended(); ms magics = (VT == MVT::i32) ? magic32(d) : magic64(d); // Multiply the numerator (operand 0) by the magic value |