aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-07 06:10:46 +0000
committerChris Lattner <sabre@nondot.org>2005-10-07 06:10:46 +0000
commit094c8fcd14a04a3bac12eb17e7e04276ce594e11 (patch)
treeb00184ad17da9f621d8667612c1a39a2298eadcb /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parentbabac05a95a1bc61580ba6ad913a1301c88f392e (diff)
Turn sdivs into udivs when we can prove the sign bits are clear. This
implements CodeGen/PowerPC/div-2.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 28215ad59b..12cfe0077f 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1556,6 +1556,17 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
return N1;
}
break;
+ case ISD::SDIV: {
+ if (CombinerEnabled) break;
+
+ // If we know the sign bits of both operands are zero, strength reduce to a
+ // udiv instead. Handles (X&15) /s 4 -> X&15 >> 2
+ uint64_t SignBit = 1ULL << (MVT::getSizeInBits(VT)-1);
+ if (MaskedValueIsZero(N2, SignBit, TLI) &&
+ MaskedValueIsZero(N1, SignBit, TLI))
+ return getNode(ISD::UDIV, VT, N1, N2);
+ break;
+ }
case ISD::AND:
case ISD::OR: