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

eliminate constant dead branches earlier? #6822

Closed
StefanKarpinski opened this issue May 12, 2014 · 2 comments
Closed

eliminate constant dead branches earlier? #6822

StefanKarpinski opened this issue May 12, 2014 · 2 comments
Labels
performance Must go faster

Comments

@StefanKarpinski
Copy link
Member

Currently, we have this:

julia> const debug = false
false

julia> function foo()
           if debug
               println("Debugging...")
           end
           1 + 2
       end
foo (generic function with 1 method)

julia> @code_llvm foo()

define i64 @julia_foo17924() {
top:
  %0 = alloca [4 x %jl_value_t*], align 8
  %.sub = getelementptr inbounds [4 x %jl_value_t*]* %0, i64 0, i64 0
  store %jl_value_t* inttoptr (i64 4 to %jl_value_t*), %jl_value_t** %.sub, align 8
  %1 = load %jl_value_t*** @jl_pgcstack, align 8, !dbg !876
  %2 = getelementptr [4 x %jl_value_t*]* %0, i64 0, i64 1, !dbg !876
  %.c = bitcast %jl_value_t** %1 to %jl_value_t*, !dbg !876
  store %jl_value_t* %.c, %jl_value_t** %2, align 8, !dbg !876
  store %jl_value_t** %.sub, %jl_value_t*** @jl_pgcstack, align 8, !dbg !876
  %3 = getelementptr [4 x %jl_value_t*]* %0, i64 0, i64 2
  store %jl_value_t* null, %jl_value_t** %3, align 8
  %4 = getelementptr [4 x %jl_value_t*]* %0, i64 0, i64 3
  store %jl_value_t* null, %jl_value_t** %4, align 8
  %5 = load %jl_value_t** %2, align 8, !dbg !877
  %6 = getelementptr inbounds %jl_value_t* %5, i64 0, i32 0, !dbg !877
  store %jl_value_t** %6, %jl_value_t*** @jl_pgcstack, align 8, !dbg !877
  ret i64 3, !dbg !877
}

It would be nice if the fact that the if debug branch can't possibly happen were detected early enough to avoid allocation of a GC frame, allowing the branch to get fully eliminated.

@ArchRobison
Copy link
Contributor

Could constant values be propagated by extending the type-inference framework? Constant propagation and type inference in Julia are similar forward-flow problems.

@JeffBezanson
Copy link
Member

dup of #5560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

No branches or pull requests

3 participants