-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Do not unroll loops on ReleaseSmall #7077
Conversation
Trivial fix for ziglang#7048, verified to work on the given test case. Fixes ziglang#7048
Well well well, I think the proper solution would be to introduce a The cooler solution would be to inhibit the unrolling only for specific loops with some kind of annotation, much better than disabling this optimization for the whole compilation unit. |
Do we really want to introduce more knobs? The intent of How about introducing an intermediate size reduction level ( |
Annotations to enable/disable unrolling of individual loops (similar to |
Well the performance impact on the generated code may be non-negligible and changing how
That may be a good compromise. |
The hardest part would be to name that new optimization level. |
I believe this is #978. I'm opposed to adding a new release mode or more global knobs. Is there a real world use case to consider that is not satisfied with this patch + the planned #978? |
In ran quite a few benchmarks ([1] [2]) a while back on multiple WebAssembly runtimes; |
@@ -218,7 +218,7 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM | |||
PMBuilder->SizeLevel = is_small ? 2 : 0; | |||
|
|||
PMBuilder->DisableTailCalls = is_debug; | |||
PMBuilder->DisableUnrollLoops = is_debug; | |||
PMBuilder->DisableUnrollLoops = is_small | is_debug; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why |
instead of ||
?
Let's follow what Clang does for -Oz and apply the `minsize` and `optsize` attributes by default. Closes ziglang#7048 Supersedes ziglang#7077
That proposal has some flaws:
What I had in mind was something like the following: fn @setScopeOptions(opt: union(enum) {
// function-level options, they can only be applied in a fn scope
Func: struct {
stack_alignment: ?usize // Replaces setStackAlign
enable_stack_canaries: bool,
runtime_safety: bool, // Can also replace setRuntimeSafety
optimize_hint: enum { None, Compact, NoOptimizations }, // Tentative naming, don't kill me
// Other options go here
},
Loop: struct {
force_unroll: bool,
force_unroll_count: usize,
},
// Who knows what else we may need
}) void; This way we can drop a few special-cased builtins and allow us to introduce as many new options we want with ease. |
Trivial fix for #7048, verified to work on the given test case.
Fixes #7048