Add specializations of prefix/postfix increment/decrement for integer types.

A few benchmarks in PreCommitBench improve at Onone (typically by a few
percent but for StringWalk it is 10%).

Swift SVN r20468
This commit is contained in:
Mark Lacey
2014-07-24 05:10:12 +00:00
parent d2ef235237
commit c69ea64c0d
6 changed files with 194 additions and 12 deletions

View File

@@ -473,6 +473,39 @@ func ${op}=(inout lhs: ${Self}, rhs: ${Self}) {
lhs = lhs ${op} rhs
}
% end
// Prefix and postfix increment and decrement.
// We already have generic versions of these, but when compiling
// -Onone we are unable to devirtualize the generic call, which
// results in worse performance than we would like for these simple
// operations (tracked by <rdar://problem/17692569>).
@transparent
public prefix func ++ (inout x: ${Self}) -> ${Self} {
x = x.successor()
return x
}
@transparent
public postfix func ++ (inout x: ${Self}) -> ${Self} {
var ret = x
x = x.successor()
return ret
}
@transparent
public prefix func -- (inout x: ${Self}) -> ${Self} {
x = x.predecessor()
return x
}
@transparent
public postfix func -- (inout x: ${Self}) -> ${Self} {
var ret = x
x = x.predecessor()
return ret
}
% end # for bits in allInts
public typealias Word = Int