summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.m.kuperstein@intel.com>2015-08-19 11:17:59 +0000
committerMichael Kuperstein <michael.m.kuperstein@intel.com>2015-08-19 11:17:59 +0000
commitdcdab4cd3aca7c587aa2d6cf20ebed1b9abe920e (patch)
treec931ebdbf850cc247cf11cd736286c8b197c40af /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent76c288062adfada1401c0b613a398519a3a1edd1 (diff)
downloadbcm5719-llvm-dcdab4cd3aca7c587aa2d6cf20ebed1b9abe920e.tar.gz
bcm5719-llvm-dcdab4cd3aca7c587aa2d6cf20ebed1b9abe920e.zip
[TLI] Refactor "is integer division cheap" queries.
This removes the isPow2SDivCheap() query, as it is not currently used in any meaningful way. isIntDivCheap() no longer relies on a state variable (as all in-tree target set it to false), but the interface allows querying based on the type optimization level. NFC. Differential Revision: http://reviews.llvm.org/D12082 llvm-svn: 245430
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d031f314f8a..c6c7cbaa069 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2176,6 +2176,7 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) {
N0, N1);
}
+ bool MinSize = DAG.getMachineFunction().getFunction()->optForMinSize();
// fold (sdiv X, pow2) -> simple ops after legalize
// FIXME: We check for the exact bit here because the generic lowering gives
// better results in that case. The target-specific lowering should learn how
@@ -2184,9 +2185,8 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) {
!cast<BinaryWithFlagsSDNode>(N)->Flags.hasExact() &&
(N1C->getAPIntValue().isPowerOf2() ||
(-N1C->getAPIntValue()).isPowerOf2())) {
- // If dividing by powers of two is cheap, then don't perform the following
- // fold.
- if (TLI.isPow2SDivCheap())
+ // If integer division is cheap, then don't perform the following fold.
+ if (TLI.isIntDivCheap(N->getValueType(0), MinSize))
return SDValue();
// Target-specific implementation of sdiv x, pow2.
@@ -2226,7 +2226,7 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) {
// If integer divide is expensive and we satisfy the requirements, emit an
// alternate sequence.
- if (N1C && !TLI.isIntDivCheap())
+ if (N1C && !TLI.isIntDivCheap(N->getValueType(0), MinSize))
if (SDValue Op = BuildSDIV(N))
return Op;
@@ -2280,8 +2280,10 @@ SDValue DAGCombiner::visitUDIV(SDNode *N) {
}
}
}
+
// fold (udiv x, c) -> alternate
- if (N1C && !TLI.isIntDivCheap())
+ bool MinSize = DAG.getMachineFunction().getFunction()->optForMinSize();
+ if (N1C && !TLI.isIntDivCheap(N->getValueType(0), MinSize))
if (SDValue Op = BuildUDIV(N))
return Op;
OpenPOWER on IntegriCloud