[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)
commit13d104bf78bb1098ab259f3165559c5ee0a5aea7
tree41fdedb77cdb6295985db654e3a525a6af775d2e
parent256ecc3c2a75a1b15b9c8b35102c6687c1adc326
[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.

llvm-svn: 224033
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
llvm/test/CodeGen/PowerPC/sdiv-pow2.ll [new file with mode: 0644]