summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-07-11 09:22:42 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-07-11 09:22:42 +0000
commitdf9d59771be1fac62718023528c678bcaf7c28b4 (patch)
treece5a9a78277e4ceb694d7de8179350f1de2a0f2c /llvm/lib/CodeGen
parent97cf111689572b6c14c04554e1194406e758ca96 (diff)
downloadbcm5719-llvm-df9d59771be1fac62718023528c678bcaf7c28b4.tar.gz
bcm5719-llvm-df9d59771be1fac62718023528c678bcaf7c28b4.zip
[DAGCombiner] Support non-uniform X%C -> X-(X/C)*C folds
First stage in PR38057 - support non-uniform constant vectors in the combine to reuse the division-by-constant logic. We can definitely do better for srem pow2 remainders (and avoid that extra multiply....) but this at least helps keep everything on the vector unit. Differential Revision: https://reviews.llvm.org/D48975 llvm-svn: 336774
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index fa0c4661e14..b2525b79807 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3297,7 +3297,10 @@ SDValue DAGCombiner::visitREM(SDNode *N) {
// by skipping the simplification if isIntDivCheap(). When div is not cheap,
// combine will not return a DIVREM. Regardless, checking cheapness here
// makes sense since the simplification results in fatter code.
- if (N1C && !N1C->isNullValue() && !TLI.isIntDivCheap(VT, Attr)) {
+ // TODO: replace matchUnaryPredicate with SelectionDAG::isKnownNeverZero(N1).
+ if (ISD::matchUnaryPredicate(
+ N1, [](ConstantSDNode *C) { return !C->isNullValue(); }) &&
+ !TLI.isIntDivCheap(VT, Attr)) {
SDValue OptimizedDiv =
isSigned ? visitSDIVLike(N0, N1, N) : visitUDIVLike(N0, N1, N);
if (OptimizedDiv.getNode() && OptimizedDiv.getOpcode() != ISD::UDIVREM &&
OpenPOWER on IntegriCloud