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

@fastmath does not handle +=, *=, etc. #9778

Closed
simonster opened this issue Jan 14, 2015 · 2 comments
Closed

@fastmath does not handle +=, *=, etc. #9778

simonster opened this issue Jan 14, 2015 · 2 comments

Comments

@simonster
Copy link
Member

e.g.:

julia> f(a) = @fastmath a*a*a*a;

julia> g(a) = @fastmath a*=a*=a*=a;

julia> code_llvm(f, (Float64,))

define double @julia_f_199956(double) {
top:
  %1 = fmul fast double %0, %0, !dbg !301
  %2 = fmul fast double %1, %1, !dbg !301
  ret double %2, !dbg !301
}

julia> code_llvm(g, (Float64,))

define double @julia_g_199959(double) {
top:
  %1 = fmul double %0, %0, !dbg !310
  %2 = fmul double %1, %0, !dbg !310
  %3 = fmul double %2, %0, !dbg !310
  ret double %3, !dbg !310
}

I think this could probably be tweaked to work by lowering a *= b to a = a * b in the @fastmath macro, or we could possibly use whatever approach we pick for #8227.

@eschnett
Copy link
Contributor

I thought that += would be expanded before @fastmath gets its hands onto the expression... Apparently not. I'll add it. Thanks!

PS: Feel free to assign this issue to me.

@eschnett
Copy link
Contributor

I have implemented this as part of #9759.

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

No branches or pull requests

3 participants