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-11610] The compiler is unable to type-check this expression in reasonable time #54018

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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11610
Radar rdar://problem/56630529
Original Reporter kuwerty (JIRA User)
Type Bug

Attachment: Download

Environment

Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
Target: x86_64-apple-darwin19.0.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 2212158c4b3316b9b643e2f66d2d5f8f

Issue Description:

$ swift -O foo.swift
foo.swift:21:21: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
    return p0*mt*mt + (p1 * (2.0*mt) + p2 * t)

foo.swift

typealias vec2 = SIMD2<Float>
struct Quadratic {
 let p0 : vec2
 let p1 : vec2
 let p2 : vec2
 init(_ p0:vec2, _ p1:vec2, _ p2:vec2) {
   self.p0 = p0
   self.p1 = p1
   self.p2 = p2
 }
 func eval(_ t:Float) -> vec2 {
  let mt : Float = 1.0 - t;
  let mtmt : Float = mt * mt
 
  // replace p0*mt*mt with p0mtmt and it succeeds but (subjectively) takes
  // a long time to compile 25 lines of code. 2s vs 0.2s when returning a literal
  //let p0mtmt : vec2 = p0 * mtmt
  return p0*mt*mt + (p1 * (2.0*mt) + p2 * t)
 }
}
@belkadan
Copy link
Contributor

@xedin, another test case for you!

@xedin
Copy link
Member

xedin commented Oct 25, 2019

@swift-ci create

@xedin
Copy link
Member

xedin commented Oct 25, 2019

kuwerty (JIRA User) Unfortunately only solution to this we have so far is to split this expression into multiple smaller ones. Meanwhile we are trying to find an answer for general problem here related to performance of generic overload type-checking.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants