-
Notifications
You must be signed in to change notification settings - Fork 127
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
Missing optimizations in flat-array.sml
benchmark
#71
Comments
Would RemoveUnused be that optimization pass? Looks like the issue may partially be documented in the comments, but I don't know enough about the exact details. |
I'm not sure if either RemoveUnused or Useless could be improved to handle this case, though RemoveUnused would be more likely. Useless actually removed useless components of data structures. The comment there isn't really relevant to the missed optimization in |
I believe that RemoveUnused could be improved to eliminate the computation of the A less conservative optimization would only mark the arguments of an |
The C and LLVM codegens, at sufficiently high optimization levels, are able to eliminate the arithmetic computation from the benchmark. Presumably, the LLVM and C compilers are able to observe that the `sum` value is unused and the `Vector.foldl` loop must terminate. See MLton#71.
The
flat-array.sml
benchmark was added to demonstrate the DeepFlatten SSA2 optimization.However, the C and LLVM codegens, at sufficiently high optimization levels, are able to eliminate the arithmetic computation from the benchmark:
Note that the LLVM and C codegens are able to optimize the computation whether or not the DeepFlatten SSA2 optimization is performed.
Presumably, the LLVM and C compilers are able to observe that the
sum
value is unused and theVector.foldl
loop must terminate.While it would be simple to "fix" the benchmark by adding a dependency on the
sum
value (e.g.,val _ = if 1105694191 <> sum then raise Fail "bug" else ()
), it would be desirable to first capture this optimization via an SSA optimization.The text was updated successfully, but these errors were encountered: