Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: use TEST/CMP with memory operands on amd64 #19485
Instrumentation after lowering suggests that a significant percentage of values on amd64 are doing a TEST or CMP on memory.
Here are some common patterns. First column is % of all values measured (during make.bash). Second column is number of values. Next column is top-level op. All following columns are ops of arguments. So 2.36% of values were a TESTL of the result of a memory load.
CMP and TEST can accept a memory arg instead of a register.
Those collectively account for >8% of values, which makes it seem potentially worth investigating.
However, this can't be done using rewrite rules, because it could lead to multiple live memory states. It could potentially be done using a peep pass, which is Keith's favorite suggestion--see #15300. I don't have any other plans, but I wanted to file this in case anyone else saw a good way.
This is a generalization of #15245.