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-7026] Compiler runs extremely slow on this bit shifting and or-ing code #49574

Open
swift-ci opened this issue Feb 18, 2018 · 3 comments
Open
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7026
Radar rdar://problem/37680424
Original Reporter acr (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Performance, TypeChecker
Assignee @xedin
Priority Medium

md5: ca2cef5b3c16ece282f62eec59b2367b

Issue Description:

This code takes several minutes to compile. On my MBP i5 2.4Ghz it takes just under 3 minutes.

I've tried on both the Standard and New build system, both behave the same.

Unfortunately I don't know why. If I break it out to several lines doing each shift on a separate line or-equaling them together the compiler has no problem.

Slow code:

struct Test {
 let computed: Int
 init(a: Int, b: Int, c: Int, d: Int, e: Int = 0, f: Int = 0, g: Int = 0, h: Int = 0) {
        computed = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h
  }
}

Fast code:

struct Test {
 let computed: Int
 init(a: Int, b: Int, c: Int, d: Int, e: Int = 0, f: Int = 0, g: Int = 0, h: Int = 0){
        var value: Int = (a << 56)
        value |= (b << 48)
        value |= (c << 40)
        value |= (d << 32)
        value |= (e << 24)
        value |= (f << 16)
        value |= (g << 8)
        value |= h
        computed = value
  }
}
@belkadan
Copy link
Contributor

@xedin, @rudkx, seems in line with the others.

@xedin
Copy link
Member

xedin commented Feb 19, 2018

Yes, this is definitely a common problem we are trying to address...

@xedin
Copy link
Member

xedin commented Feb 19, 2018

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants