Erik Eckstein
c4096bc723
Swift Optimizer: simplify builtin "once"
...
If the callee is side effect-free we can remove the whole builtin "once".
2023-05-08 21:23:36 +02:00
Erik Eckstein
9b51e69dac
Swift Optimizer: constant fold builtins in the simplification passes
2023-05-08 21:23:36 +02:00
Erik Eckstein
88973a3cd5
Swift Optimizer: add simplification for tuple_extract
...
Replace tuple_extract(tuple(x)) -> x
2023-05-08 21:23:36 +02:00
Erik Eckstein
5a3ab6ee2e
Swift Optimizer: add simplifications for destructure_struct and destructure_tuple
...
Eliminate the redundant instruction pair
```
%t = tuple (%0, %1, %2)
(%3, %4, %5) = destructure_tuple %t
```
and replace the results %3, %4, %5 with %0, %1, %2, respectively.
The same for structs.
2023-05-08 21:23:36 +02:00
Erik Eckstein
0a05124023
Swift Optimizer: add simplification of debug_step
...
When compiling with optimizations, unconditionally remove `debug_step`
2023-05-08 21:23:36 +02:00
Erik Eckstein
a8c9aae1e0
Swift Optimizer: add simplification for cond_fail
2023-05-08 21:23:36 +02:00
Erik Eckstein
318c30895f
Swift Optimizer: eliminate ARC operations on types which are marked as immortal
...
A type (mostly classes) can be attributed with `@_semantics("arc.immortal")`.
ARC operations on values of such types are eliminated.
This is useful for the bridged SIL objects in the swift compiler sources.
2023-03-14 21:07:03 +01:00
Erik Eckstein
f1095556c9
Swift SIL: let var UnaryInstruction.operand return an Operand and not a Value
...
To avoid confusion. Instead add specific getters for unary instructions with dedicated names.
NFC
2023-02-21 17:57:29 +01:00
Erik Eckstein
40ed0fb388
Swift Optimizer: fix a crash when simplifying same-metatype comparisons of function types
...
The instance type of a metatype instruction is not necessarily a legal lowered SIL Type.
Lower the type before converting it to a SILType.
rdar://105502403
2023-02-15 21:14:32 +01:00
Erik Eckstein
85210a4e91
Swift Optimizer: make some SILCombine optimizations available for the "Simplification" pass
...
* begin_cow_mutation
* global_value
* strong_retain and strong_release
So far, those simplifications did only run in SILCombine. Now they are also considered in the swift Simplification pass.
2023-02-09 06:50:05 +01:00
Erik Eckstein
1c70060e01
Swift Optimizer: add Onone simplification of struct_extract instructions
2023-02-09 06:50:05 +01:00
Erik Eckstein
20edeb6a8c
Swift Optimizer: add Onone simplification of unchecked_enum_data instructions
2023-02-09 06:50:05 +01:00
Erik Eckstein
4cf62696b6
Swift Optimizer: add Onone simplification of cond_br instructions
2023-02-09 06:50:05 +01:00
Erik Eckstein
d56ed65718
Swift Optimizer: add Onone simplification of some builtin instructions
...
* `Builtin.isConcrete`
* `Builtin.is_same_metatype`
2023-02-09 06:50:05 +01:00
Erik Eckstein
3f35a1d869
Swift Optimizer: add Onone simplification of branch instructions
2023-02-09 06:50:05 +01:00
Erik Eckstein
f1c6ed681d
Swift Optimizer: add Onone simplification of apply instructions
2023-02-09 06:50:05 +01:00
Erik Eckstein
ea746479ad
SIL Optimizer: rename directory InstructionPasses -> InstructionSimplification
2023-01-16 16:16:51 +01:00