Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9433] Negating CGFloat generates call to CGFloat.negate() instead of fneg #51897

Closed
aroben opened this issue Dec 7, 2018 · 4 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay standard library Area: Standard library umbrella

Comments

@aroben
Copy link

aroben commented Dec 7, 2018

Previous ID SR-9433
Radar rdar://problem/46496529
Original Reporter @aroben
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, SDKOverlay
Assignee @stephentyrone
Priority Medium

md5: 93e119d91a06e51d19f8442b4fb687c3

Issue Description:

$ cat test.swift
import Foundation

#if CG
import CoreGraphics
typealias Dub = CGFloat
#else
typealias Dub = Double
#endif

@inline(never)
public func blackHole<T>(_ x: T) {
}

let a = Double(arc4random())
blackHole(-Dub(a))

$ swiftc -Osize -whole-module-optimization -module-name test -o double test.swift
$ swiftc -Osize -whole-module-optimization -module-name test -D CG -o cgfloat test.swift

If you compare the two binaries you can see that the CGFloat version calls CGFloat.negate() while the Double version just uses an fneg instruction.

@belkadan
Copy link
Contributor

cc @stephentyrone

@stephentyrone
Copy link
Member

Looks like CGFloat is missing some @_transparent annotations.

@stephentyrone
Copy link
Member

Included with #21090

@stephentyrone
Copy link
Member

This is done in Swift 5.0

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants