[SR-12715] Optimiser fails to elide bounds check that is guaranteed to succeed on constant-size array. #55160
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
SILOptimizer
Area → compiler: SIL optimization passes
Environment
swift-5.2-RELEASE
Additional Detail from JIRA
md5: a42e10c38447fad0977a4ea580b205ea
Issue Description:
The following code:
Generates this assembly in Swift 5.2 when compiled with -O:
Due to the outlined call to
generic specialization <Swift.Range<Swift.Int>> of Swift._copyCollectionToContiguousArray<A where A: Swift.Collection>(A) -> Swift.ContiguousArray<A.Element>
the compiler has failed to observe that[rax + 16]
will always be1024
, and so thejae
branch will never be taken. It would be good if the compiler could elide the bounds check.The text was updated successfully, but these errors were encountered: