From: Nate Begeman Date: Fri, 17 Feb 2006 07:26:20 +0000 (+0000) Subject: Don't expand sdiv by power of two before legalize, since it will likely X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cd6a6ed0a9d4b63535b430bf4c5c4396cd9d4e86;p=oota-llvm.git Don't expand sdiv by power of two before legalize, since it will likely generate illegal nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26261 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 48bb2024e4d..4d5dcd780e3 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -731,8 +731,8 @@ SDOperand DAGCombiner::visitSDIV(SDNode *N) { if (TLI.MaskedValueIsZero(N1, SignBit) && TLI.MaskedValueIsZero(N0, SignBit)) return DAG.getNode(ISD::UDIV, N1.getValueType(), N0, N1); - // fold (sdiv X, pow2) -> simple ops. - if (N1C && N1C->getValue() && !TLI.isIntDivCheap() && + // fold (sdiv X, pow2) -> simple ops after legalize + if (N1C && N1C->getValue() && !TLI.isIntDivCheap() && AfterLegalize && (isPowerOf2_64(N1C->getSignExtended()) || isPowerOf2_64(-N1C->getSignExtended()))) { // If dividing by powers of two is cheap, then don't perform the following