• Keith Randall's avatar
    cmd/compile: don't use CMOV ops to compute load addresses · 0b79dde1
    Keith Randall authored
    We want to issue loads as soon as possible, especially when they
    are going to miss in the cache. Using a conditional move (CMOV) here:
    
    i := ...
    if cond {
       i++
    }
    ... = a[i]
    
    means that we have to wait for cond to be computed before the load
    is issued. Without a CMOV, if the branch is predicted correctly the
    load can be issued in parallel with computing cond.
    Even if the branch is predicted incorrectly, maybe the speculative
    load is close to the real load, and we get a prefetch for free.
    In the worst case, when the prediction is wrong and the address is
    way off, we only lose by the time difference between the CMOV
    latency (~2 cycles) and the mispredict restart latency (~15 cycles).
    
    We only squash CMOVs that affect load addresses. Results of CMOVs
    that are used for other things (store addresses, store values) we
    use as before.
    
    Fixes #26306
    
    Change-Id: I82ca14b664bf05e1d45e58de8c4d9c775a127ca1
    Reviewed-on: https://go-review.googlesource.com/c/145717
    Run-TryBot: Keith Randall <khr@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
    0b79dde1
Name
Last commit
Last update
..
README Loading commit data...
arithmetic.go Loading commit data...
bitfield.go Loading commit data...
bits.go Loading commit data...
comparisons.go Loading commit data...
condmove.go Loading commit data...
copy.go Loading commit data...
floats.go Loading commit data...
issue22703.go Loading commit data...
issue25378.go Loading commit data...
mapaccess.go Loading commit data...
maps.go Loading commit data...
math.go Loading commit data...
mathbits.go Loading commit data...
memcombine.go Loading commit data...
memops.go Loading commit data...
noextend.go Loading commit data...
rotate.go Loading commit data...
shift.go Loading commit data...
slices.go Loading commit data...
stack.go Loading commit data...
strings.go Loading commit data...
structs.go Loading commit data...