• Matthew Dempsky's avatar
    runtime: simplify cpuprof hash calculation · 481ce36e
    Matthew Dempsky authored
    "x*41" computes the same value as "x*31 + x*7 + x*3" and (when
    compiled by gc) requires just one multiply instruction instead of
    three.
    
    Alternatively, the expression could be written as "(x<<2+x)<<3 + x" to
    use shifts instead of multiplies (which is how GCC optimizes "x*41").
    But gc currently emits suboptimal instructions for this expression
    anyway (e.g., separate SHL+ADD instructions rather than LEA on
    386/amd64). Also, if such an optimization was worthwhile, it would
    seem better to implement it as part of gc's strength reduction logic.
    
    Change-Id: I7156b793229d723bbc9a52aa9ed6111291335277
    Reviewed-on: https://go-review.googlesource.com/1830Reviewed-by: 's avatarMinux Ma <minux@golang.org>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    481ce36e
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
include Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...