summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-08-23 01:06:51 +0000
committerDan Gohman <gohman@apple.com>2008-08-23 01:06:51 +0000
commit95d1056831314f9cd2690e6fb32bc3746e60c7d5 (patch)
treebe451bb5469ffcf00d315f54961d0e06dc4d2878 /llvm/lib/CodeGen
parent4e7713c04d24f38a5d27050b149ab12249eeb4d7 (diff)
downloadbcm5719-llvm-95d1056831314f9cd2690e6fb32bc3746e60c7d5.tar.gz
bcm5719-llvm-95d1056831314f9cd2690e6fb32bc3746e60c7d5.zip
Avoid creating shift-by-zero SDNodes in the common case of
i8* getelementptr. DAGCombine eliminates these, but this is a fairly common case. llvm-svn: 55214
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index e13cfc0fa03..147f45c8b53 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -2814,16 +2814,17 @@ void SelectionDAGLowering::visitGetElementPtr(User &I) {
// If this is a multiply by a power of two, turn it into a shl
// immediately. This is a very common case.
- if (isPowerOf2_64(ElementSize)) {
- unsigned Amt = Log2_64(ElementSize);
- IdxN = DAG.getNode(ISD::SHL, N.getValueType(), IdxN,
- DAG.getConstant(Amt, TLI.getShiftAmountTy()));
- N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
- continue;
+ if (ElementSize != 1) {
+ if (isPowerOf2_64(ElementSize)) {
+ unsigned Amt = Log2_64(ElementSize);
+ IdxN = DAG.getNode(ISD::SHL, N.getValueType(), IdxN,
+ DAG.getConstant(Amt, TLI.getShiftAmountTy()));
+ } else {
+ SDValue Scale = DAG.getIntPtrConstant(ElementSize);
+ IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN, Scale);
+ }
}
-
- SDValue Scale = DAG.getIntPtrConstant(ElementSize);
- IdxN = DAG.getNode(ISD::MUL, N.getValueType(), IdxN, Scale);
+
N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
}
}
OpenPOWER on IntegriCloud