5 Commits

Author SHA1 Message Date
Erik Eckstein
9e70eb814c InitializeStaticGlobals: handle InlineArray.init(repeating:) also for arm64_32
This needs matching a different builtin for scalar conversion for the `index_addr` index.

Fixes a test failure on watchos
rdar://151761870
2025-05-22 15:33:27 +02:00
Erik Eckstein
d7580e4919 Optimizer: move the Value.lookThroughTruncOrBitCast from SimplifyPointerToAddress.swift to OptUtils.swift 2025-05-20 20:46:33 +02:00
Erik Eckstein
3f95ce9645 Optimizer: fix spelling of the Simplifiable protocol
Rename `Simplifyable` -> `Simplifiable`

NFC
2025-02-12 09:01:11 +01:00
Erik Eckstein
9aff288be4 Optimizer: re-implement the pointer_to_address SILCombine peephole optimizations in swift
Which consists of
* removing redundant `address_to_pointer`-`pointer_to_address` pairs
* optimize `index_raw_pointer` of a manually computed stride to `index_addr`
* remove or increase the alignment based on a "assumeAlignment" builtin

This is a big code cleanup but also has some functional differences for the `address_to_pointer`-`pointer_to_address` pair removal:

* It's not done if the resulting SIL would result in a (detectable) use-after-dealloc_stack memory lifetime failure.
* It's not done if `copy_value`s must be inserted or borrow-scopes must be extended to comply with ownership rules (this was the task of the OwnershipRAUWHelper).

Inserting copies is bad anyway.
Extending borrow-scopes would only be required if the original lifetime of the pointer extends a borrow scope - which shouldn't happen in save code. Therefore this is a very rare case which is not worth handling.
2024-12-21 08:28:22 +01:00
Erik Eckstein
89d3326ff4 Swift Optimizer: add a simplification for pointer_to_address
For a redundant pair of pointer-address conversions, e.g.

   %2 = address_to_pointer %1
   %3 = pointer_to_address %2 [strict]

replace all uses of %3 with %1.
2023-08-10 20:49:20 +02:00