mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib: Do the Array fast-path check with a single array property call.
Now that we can check isNative and NoDTC (no deffered type check needed) with a single bit-mask operation, it makes sense to have a single array property call for it. I replaced the the semantics call array.props.needsElementTypeCheck with array.props.isNativeNoDTC, which is the combination of isNative && !needsElementTypeCheck. I kept array.props.isNative, which is not used for now, but might be useful in the future, e.g. for array operations which don't care about type checks. The optimized SIL for a class array access arr[i] now contains the minimum of 4 basic blocks. PerfTests show +25% for DeltaBlue and some improvemements for -Onone. Swift SVN r26871
This commit is contained in:
@@ -45,7 +45,7 @@ bool swift::ArraySemanticsCall::isValidSignature() {
|
||||
// All other calls can be consider valid.
|
||||
default: break;
|
||||
case ArrayCallKind::kArrayPropsIsNative:
|
||||
case ArrayCallKind::kArrayPropsNeedsTypeCheck: {
|
||||
case ArrayCallKind::kArrayPropsIsNativeNoDTC: {
|
||||
// @guaranteed/@owned Self
|
||||
if (SemanticsCall->getNumArguments() != 1)
|
||||
return false;
|
||||
@@ -120,8 +120,8 @@ ArrayCallKind swift::ArraySemanticsCall::getKind() const {
|
||||
auto Kind =
|
||||
llvm::StringSwitch<ArrayCallKind>(F->getSemanticsString())
|
||||
.Case("array.props.isNative", ArrayCallKind::kArrayPropsIsNative)
|
||||
.Case("array.props.needsElementTypeCheck",
|
||||
ArrayCallKind::kArrayPropsNeedsTypeCheck)
|
||||
.Case("array.props.isNativeNoDTC",
|
||||
ArrayCallKind::kArrayPropsIsNativeNoDTC)
|
||||
.Case("array.init", ArrayCallKind::kArrayInit)
|
||||
.Case("array.uninitialized", ArrayCallKind::kArrayUninitialized)
|
||||
.Case("array.check_subscript", ArrayCallKind::kCheckSubscript)
|
||||
@@ -211,7 +211,7 @@ bool swift::ArraySemanticsCall::canHoist(SILInstruction *InsertBefore,
|
||||
|
||||
case ArrayCallKind::kCheckIndex:
|
||||
case ArrayCallKind::kArrayPropsIsNative:
|
||||
case ArrayCallKind::kArrayPropsNeedsTypeCheck:
|
||||
case ArrayCallKind::kArrayPropsIsNativeNoDTC:
|
||||
case ArrayCallKind::kGetElementAddress:
|
||||
return canHoistArrayArgument(SemanticsCall, getSelf(), InsertBefore, DT);
|
||||
|
||||
@@ -333,7 +333,7 @@ ApplyInst *swift::ArraySemanticsCall::hoistOrCopy(SILInstruction *InsertBefore,
|
||||
auto Kind = getKind();
|
||||
switch (Kind) {
|
||||
case ArrayCallKind::kArrayPropsIsNative:
|
||||
case ArrayCallKind::kArrayPropsNeedsTypeCheck: {
|
||||
case ArrayCallKind::kArrayPropsIsNativeNoDTC: {
|
||||
assert(SemanticsCall->getNumArguments() == 1 &&
|
||||
"Expect 'self' parameter only");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user