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

Open
randall77 opened this Issue Mar 1, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@randall77
Contributor

randall77 commented Mar 1, 2016

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

MOVL    runtime.writeBarrier(SB), AX
TESTB   AL, AL
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.

@drchase

@bradfitz bradfitz added the Performance label Mar 1, 2016

@minux

This comment has been minimized.

Member

minux 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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment