mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
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
This commit is contained in:
@@ -2814,16 +2814,17 @@ void SelectionDAGLowering::visitGetElementPtr(User &I) {
|
|||||||
|
|
||||||
// If this is a multiply by a power of two, turn it into a shl
|
// If this is a multiply by a power of two, turn it into a shl
|
||||||
// immediately. This is a very common case.
|
// immediately. This is a very common case.
|
||||||
if (isPowerOf2_64(ElementSize)) {
|
if (ElementSize != 1) {
|
||||||
unsigned Amt = Log2_64(ElementSize);
|
if (isPowerOf2_64(ElementSize)) {
|
||||||
IdxN = DAG.getNode(ISD::SHL, N.getValueType(), IdxN,
|
unsigned Amt = Log2_64(ElementSize);
|
||||||
DAG.getConstant(Amt, TLI.getShiftAmountTy()));
|
IdxN = DAG.getNode(ISD::SHL, N.getValueType(), IdxN,
|
||||||
N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
|
DAG.getConstant(Amt, TLI.getShiftAmountTy()));
|
||||||
continue;
|
} 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);
|
N = DAG.getNode(ISD::ADD, N.getValueType(), N, IdxN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user