Commit Graph

6 Commits

Author SHA1 Message Date
Erik Eckstein
3f95ce9645 Optimizer: fix spelling of the Simplifiable protocol
Rename `Simplifyable` -> `Simplifiable`

NFC
2025-02-12 09:01:11 +01:00
Erik Eckstein
73e36e2282 SimplifyDestructure: canonicalize destructure_tuple and destructure_struct for trivial tuples/structs
Replace destructure_tuple with tuple_extract instructions and destructure_struct with struct_extract instructions.
This canonicalization helps other optimizations to e.g. CSE tuple_extract/struct_extract.
2024-12-11 12:32:33 +01:00
Meghana Gupta
7508a90af0 Enable destructure_struct/destructure_tuple simplifications in silcombine 2024-02-26 10:58:08 -08:00
Erik Eckstein
0509a056fb SwiftCompilerSources: improve APIs for UseList
Make filter APIs for UseList chainable by adding them to Sequence where Element == Operand

For example, it allows to write:
```
let singleUse = value.uses.ignoreDebugUses.ignoreUsers(ofType: EndAccessInst.self).singleUse
```

Also, add `UseList.getSingleUser(notOfType:)`
2023-11-13 20:18:07 +01:00
Erik Eckstein
6ff3b91fe4 SimplifyDestructure: support simplifying a destructure_struct with a copy_value in place
Replace
```
  %s = struct (%0, %1, %2)
  %c = copy_value %s           // can also be a chain of multiple copies
  (%3, %4, %5) = destructure_struct %c
```
with
```
  %c0 = copy_value %0
  %c1 = copy_value %1
  %c2 = copy_value %2
  %s = struct (%0, %1, %2)    // keep the original struct
```
and replace the results %3, %4, %5 with %c0, %c1, %c2, respectively.
2023-11-09 18:34:53 +01: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