Commit Graph

18 Commits

Author SHA1 Message Date
Erik Eckstein
e28125b106 stdlib: specialize OptionSet.insert for FixedWidthInteger raw-values
This lets the generated code boil down to a single or-instruction.

rdar://157958188
2025-08-12 08:05:49 +02:00
Erik Eckstein
a1334973c9 SILPrinter: don't print operand types in static initializers of globals
This was missing from https://github.com/swiftlang/swift/pull/77763
2024-11-22 15:19:25 +01:00
Emil Pedersen
16c57aefcd [DebugInfo] Salvage integer literals 2024-04-26 16:31:16 -07:00
Erik Eckstein
beb46eb624 Use the new escape and side effects in alias analysis 2022-12-21 17:41:46 +01:00
Erik Eckstein
741c6c38df Swift Optimizer: add the ComputeSideEffects pass.
Computes the side effects for a function, which consists of argument- and global effects.
This is similar to the ComputeEscapeEffects pass, just for side-effects.
2022-10-05 07:38:11 +02:00
Meghana Gupta
0992e7731f Enable GenericSpecializer on OSSA by default (#34899) 2020-12-01 21:19:17 -08:00
Meghana Gupta
632b5ce0c8 Ignore OnFastPath builtin while looking for valid static initializer of a global variable 2020-06-11 10:06:10 -07:00
Erik Eckstein
93ff8b0d96 stdlib: make sure that SetAlgebra.init(sequence) is on the fast path.
In order to fully optimize OptionSet literals, it's important that this function is inlined and fully optimized.
So far this was done by chance, but with COW representation it needs a hint to the optimizer.
2020-05-29 08:46:54 +02:00
Erik Eckstein
966d617625 SIL optimizer: propagate count and capacity from empty Array/Set/Dictionary singletons.
Constant-propagate the 0 value when loading "count" or "capacity" from the empty Array, Set or Dictionary storage.
On high-level SIL this optimization is also done by the ArrayCountPropagation pass, but only for Array.
And even for Array it's sometimes needed to propagate the empty-array count when high-level semantics function are already inlined.

Fixes an optimization deficiency for empty OptionSet literals.

https://bugs.swift.org/browse/SR-12046
rdar://problem/58861171
2020-01-24 14:47:30 +01:00
Michael Gottesman
269762eee3 [ownership] Enable ownership lowering /after/ the diagnostic passes.
I also updated the last group of straggling tests.
2019-11-17 11:34:43 -08:00
Erik Eckstein
8f26405e24 tests: fix the commandline for the optionset test
The purpose of this test is to check if the compiler optimizes optionsets as expected. There should not be any additional tweaks necessary, like disabling exclusivity checks.
Fortunately, optimizations are good enough in the meantime that this test also works with enabled exclusivity checking.
2019-08-29 18:07:40 +02:00
Andrew Trick
a17dbc7c74 Enable run-time exclusivity checking in release mode.
This change could impact Swift programs that previously appeared
well-behaved, but weren't fully tested in debug mode. Now, when running
in release mode, they may trap with the message "error: overlapping
accesses...".

Recent optimizations have brought performance where I think it needs
to be for adoption. More optimizations are planned, and some
benchmarks should be further improved, but at this point we're ready
to begin receiving bug reports. That will help prioritize the
remaining work for Swift 5.

Of the 656 public microbenchmarks in the Swift repository, there are
still several regressions larger than 10%:

TEST                    OLD      NEW      DELTA      RATIO
ClassArrayGetter2       139      1307     +840.3%    **0.11x**
HashTest                631      1233     +95.4%     **0.51x**
NopDeinit               21269    32389    +52.3%     **0.66x**
Hanoi                   1478     2166     +46.5%     **0.68x**
Calculator              127      158      +24.4%     **0.80x**
Dictionary3OfObjects    391      455      +16.4%     **0.86x**
CSVParsingAltIndices2   526      604      +14.8%     **0.87x**
Prims                   549      626      +14.0%     **0.88x**
CSVParsingAlt2          1252     1411     +12.7%     **0.89x**
Dictionary4OfObjects    206      232      +12.6%     **0.89x**
ArrayInClass            46       51       +10.9%     **0.90x**

The common pattern in these benchmarks is to define an array of data
as a class property and to repeatedly access that array through the
class reference. Each of those class property accesses now incurs a
runtime call. Naturally, introducing a runtime call in a loop that
otherwise does almost no work incurs substantial overhead. This is
similar to the issue caused by automatic reference counting. In some
cases, more sophistacated optimization will be able to determine the
same object is repeatedly accessed. Furthermore, the overhead of the
runtime call itself can be improved. But regardless of how well we
optimize, there will always a class of microbenchmarks in which the
runtime check has a noticeable impact.

As a general guideline, avoid performing class property access within
the most performance critical loops, particularly on different objects
in each loop iteration. If that isn't possible, it may help if the
visibility of those class properties is private or internal.
2018-11-02 16:54:31 -07:00
Erik Eckstein
6d3f74a2a0 SILOptimizer: only do SROA when it has a benefit.
Replacing an alloc_stack of a struct/tuple with multiple alloc_stacks of the struct/tuple elements should only be done if the elements are somehow accessed individually.
If not, e.g. if the whole struct/tuple is just copied, there is no benefit of doing SROA.

Although this change has little impact by its own (some small code size wins), it is important for the improvement of let-property optimization.
2018-09-04 11:21:27 -07:00
Michael Gottesman
a1089a2923 [+0-all-args] Mark the storage parameter to _adoptStorage as a +1 parameter.
This fixes the optionset test with +0 enabled. It is now re-enabled.

rdar://38152291
2018-03-27 18:25:39 -07:00
Joe Shajrawi
a399d9bf60 XFAIL test wherein optimizations are not kicking in when compiling with a +0 runtime.
Turning these back on is tracked by:

rdar://38152291
2018-03-08 19:26:35 -08:00
Erik Eckstein
14ae2c2d92 Add a test to check if OptionSet literals are fully folded 2018-01-19 11:33:28 -08:00
eeckstein
b126b62256 Revert "Optimization changes to completely fold OptionSet literals" 2018-01-18 22:05:07 -08:00
Erik Eckstein
86b821c48f Add a test to check if OptionSet literals are fully folded 2018-01-18 18:27:17 -08:00