diff options
author | Dan Gohman <gohman@apple.com> | 2008-08-23 01:06:51 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-08-23 01:06:51 +0000 |
commit | 6679906d9724868bf2198e04952ba42f31d7b7fe (patch) | |
tree | 6fc7756c69f468a79970204e319560367771ec5b | |
parent | 6f17966a804f53518aa06fd0b5f035d5b1a51589 (diff) |
Avoid creating shift-by-zero SDNodes in the common case of
i8* getelementptr. DAGCombine eliminates these, but this is
a fairly common case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55214 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index e13cfc0fa0..147f45c8b5 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/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); } } |