Restore CanType-based micro-optimizations.

This reverts commit 5036806e5a.
However, it preserves a pair of changes to the SIL optimizer
relating to walking through optional types.
This commit is contained in:
John McCall
2017-03-14 11:30:06 -04:00
parent f3bfc777be
commit 897f5ab7c5
15 changed files with 144 additions and 88 deletions

View File

@@ -1709,12 +1709,12 @@ optimizeBridgedCasts(SILInstruction *Inst,
// ensure that types are not existential,
// and that one of the types is a class and another
// one is a struct.
if (source->isAnyExistentialType() ||
target->isAnyExistentialType() ||
(source->getClassOrBoundGenericClass() &&
!target->getStructOrBoundGenericStruct()) ||
(target->getClassOrBoundGenericClass() &&
!source->getStructOrBoundGenericStruct()))
if (source.isAnyExistentialType() ||
target.isAnyExistentialType() ||
(source.getClassOrBoundGenericClass() &&
!target.getStructOrBoundGenericStruct()) ||
(target.getClassOrBoundGenericClass() &&
!source.getStructOrBoundGenericStruct()))
return nullptr;
// Casts involving non-bound generic types cannot be optimized.
@@ -2277,7 +2277,7 @@ CastOptimizer::optimizeCheckedCastBranchInst(CheckedCastBranchInst *Inst) {
return nullptr;
// Get the type used to initialize the existential.
auto ConcreteTy = FoundIERI->getFormalConcreteType();
if (ConcreteTy->isAnyExistentialType())
if (ConcreteTy.isAnyExistentialType())
return nullptr;
// Get the SIL metatype of this type.
auto EMT = dyn_cast<AnyMetatypeType>(EMI->getType().getSwiftRValueType());