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

cmd/compile: SSA, use CMPconst for write barrier #14587

randall77 opened this issue Mar 1, 2016 · 2 comments


Copy link

commented Mar 1, 2016

right now we generate this code for a write barrier test:

MOVL    runtime.writeBarrier(SB), AX
JNE ...

We should really do:

CMPB    $1, runtime.writeBarrier(SB)
JEQ ...

One less instruction, no register required.
It's not easy to do now because flagalloc doesn't like operations that take a memory input and generate a flag output (because it wants to be able to move the flag-generation instructions around).

Figure out a way to fix this. Maybe introduce a new block type BlockWBCheck that takes a memory control value and has 2 successors. It has the CMPx implicit inside it. It would need to be marked as clobbering flags.


@bradfitz bradfitz added the Performance label Mar 1, 2016


This comment has been minimized.

Copy link

commented Mar 1, 2016

If the only use of a load is a CMP with const,
I think we could combine the load and CMP
into CMP $const, MEM.

Actually, this transform should be generic
for x86 and not necessarily limited to CMP.

I think having a package global bool that
is queried often is a pretty common scenario.
(it probably also makes sense to align such
variable to cache line size, so that there is
no false sharing.)


This comment has been minimized.

Copy link
Contributor Author

commented Apr 2, 2019

This is done.

@randall77 randall77 closed this Apr 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.