[PowerPC] Implement BuildSDIVPow2, lower i64 pow2 sdiv using sradi
authorHal Finkel <hfinkel@anl.gov>
Thu, 11 Dec 2014 18:37:52 +0000 (18:37 +0000)
committerHal Finkel <hfinkel@anl.gov>
Thu, 11 Dec 2014 18:37:52 +0000 (18:37 +0000)
commit31f6bdbbbeb24616a5e6bb06b720055533750178
treeaaa40fcb920eccd0036b279b2295d53dbb5ba380
parentde15d01f9d48701b6b6830670b858d366172f096
[PowerPC] Implement BuildSDIVPow2, lower i64 pow2 sdiv using sradi

PPCISelDAGToDAG contained existing code to lower i32 sdiv by a power-of-2 using
srawi/addze, but did not implement the i64 case. DAGCombine now contains a
callback specifically designed for this purpose (BuildSDIVPow2), and part of
the logic has been moved to an implementation of that callback. Doing this
lowering using BuildSDIVPow2 likely does not matter, compared to handling
everything in PPCISelDAGToDAG, for the positive divisor case, but the negative
divisor case, which generates an additional negation, can potentially benefit
from additional folding from DAGCombine. Now, both the i32 and the i64 cases
have been implemented.

Fixes PR20732.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224033 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCISelDAGToDAG.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.h
test/CodeGen/PowerPC/sdiv-pow2.ll [new file with mode: 0644]