summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-06-16 08:14:38 +0000
committerDuncan Sands <baldrick@free.fr>2008-06-16 08:14:38 +0000
commit37c1f5267b2c9af6b91d5c5c5dff932a9ec652bc (patch)
tree21fb77c179941aa63503142c4293af44f301f292 /llvm
parent51c75c0c95a19e750e71eece8cda65406622e334 (diff)
downloadbcm5719-llvm-37c1f5267b2c9af6b91d5c5c5dff932a9ec652bc.tar.gz
bcm5719-llvm-37c1f5267b2c9af6b91d5c5c5dff932a9ec652bc.zip
Allow these transforms for types like i256 while
still excluding types like i1 (not byte sized) and i120 (loading an i120 requires loading an i64, an i32, an i16 and an i8, which is expensive). llvm-svn: 52310
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/CodeGen/ValueTypes.h6
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
2 files changed, 12 insertions, 8 deletions
diff --git a/llvm/include/llvm/CodeGen/ValueTypes.h b/llvm/include/llvm/CodeGen/ValueTypes.h
index ef70dab3fea..dd9b4ae309d 100644
--- a/llvm/include/llvm/CodeGen/ValueTypes.h
+++ b/llvm/include/llvm/CodeGen/ValueTypes.h
@@ -266,6 +266,12 @@ namespace llvm {
return (getSizeInBits() & 7) == 0;
}
+ /// isRound - Return true if the size is a power-of-two number of bytes.
+ inline bool isRound() const {
+ unsigned BitSize = getSizeInBits();
+ return BitSize >= 8 && !(BitSize & (BitSize - 1));
+ }
+
/// bitsGT - Return true if this has more bits than VT.
inline bool bitsGT(MVT VT) const {
return getSizeInBits() > VT.getSizeInBits();
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 462a384d0a9..9db98793637 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1787,10 +1787,9 @@ SDOperand DAGCombiner::visitAND(SDNode *N) {
EVT = MVT::getIntegerVT(ActiveBits);
MVT LoadedVT = LN0->getMemoryVT();
- // Do not generate loads of extended integer types since these can be
- // expensive (and would be wrong if the type is not byte sized).
- if (EVT != MVT::Other && LoadedVT.bitsGT(EVT) && EVT.isSimple() &&
- EVT.isByteSized() && // Exclude MVT::i1, which is simple.
+ // Do not generate loads of non-round integer types since these can
+ // be expensive (and would be wrong if the type is not byte sized).
+ if (EVT != MVT::Other && LoadedVT.bitsGT(EVT) && EVT.isRound() &&
(!AfterLegalize || TLI.isLoadXLegal(ISD::ZEXTLOAD, EVT))) {
MVT PtrType = N0.getOperand(1).getValueType();
// For big endian targets, we need to add an offset to the pointer to
@@ -3187,10 +3186,9 @@ SDOperand DAGCombiner::ReduceLoadWidth(SDNode *N) {
}
}
- // Do not generate loads of extended integer types since these can be
- // expensive (and would be wrong if the type is not byte sized).
- if (ISD::isNON_EXTLoad(N0.Val) && N0.hasOneUse() && VT.isSimple() &&
- VT.isByteSized() && // Exclude MVT::i1, which is simple.
+ // Do not generate loads of non-round integer types since these can
+ // be expensive (and would be wrong if the type is not byte sized).
+ if (ISD::isNON_EXTLoad(N0.Val) && N0.hasOneUse() && VT.isRound() &&
// Do not change the width of a volatile load.
!cast<LoadSDNode>(N0)->isVolatile()) {
assert(N0.getValueType().getSizeInBits() > EVTBits &&
OpenPOWER on IntegriCloud