mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 17:32:49 +00:00
Add fast paths to ScalarEvolution::getSizeOf and getOffsetOf, as
they're used a lot by getNodeForGEP, which can be called a lot. This speeds up -iv-users by around 15% on several testcases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101083 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8cc21cac89
commit
6ab10f69a9
@ -2254,6 +2254,13 @@ const SCEV *ScalarEvolution::getUMinExpr(const SCEV *LHS,
|
||||
}
|
||||
|
||||
const SCEV *ScalarEvolution::getSizeOfExpr(const Type *AllocTy) {
|
||||
// If we have TargetData, we can bypass creating a target-independent
|
||||
// constant expression and then folding it back into a ConstantInt.
|
||||
// This is just a compile-time optimization.
|
||||
if (TD)
|
||||
return getConstant(TD->getIntPtrType(getContext()),
|
||||
TD->getTypeAllocSize(AllocTy));
|
||||
|
||||
Constant *C = ConstantExpr::getSizeOf(AllocTy);
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
||||
C = ConstantFoldConstantExpression(CE, TD);
|
||||
@ -2271,6 +2278,13 @@ const SCEV *ScalarEvolution::getAlignOfExpr(const Type *AllocTy) {
|
||||
|
||||
const SCEV *ScalarEvolution::getOffsetOfExpr(const StructType *STy,
|
||||
unsigned FieldNo) {
|
||||
// If we have TargetData, we can bypass creating a target-independent
|
||||
// constant expression and then folding it back into a ConstantInt.
|
||||
// This is just a compile-time optimization.
|
||||
if (TD)
|
||||
return getConstant(TD->getIntPtrType(getContext()),
|
||||
TD->getStructLayout(STy)->getElementOffset(FieldNo));
|
||||
|
||||
Constant *C = ConstantExpr::getOffsetOf(STy, FieldNo);
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
||||
C = ConstantFoldConstantExpression(CE, TD);
|
||||
|
Loading…
x
Reference in New Issue
Block a user