You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package p
var (
s*intbbool
)
funcf() {
varq*intifb {
q=new(int)
} else {
q=new(int)
}
s=q
}
This code is a bit silly, but it's the smallest reproduction I have handy. :)
When compiled, this code tests b, and on each branch it contains an LEAQ of type.int. The LEAQ should be hoisted above the branch, since it is needed immediately in each case, and there are registers to spare.
The CSE pass does its work, and there is a single LEAQ instruction going into regalloc. However, early in regalloc, we decide to issue it every place we need it:
ifs.values[v.ID].rematerializeable {
// Value is rematerializeable, don't issue it here.// It will get issued just before each use (see// allocValueToReg).for_, a:=rangev.Args {
a.Uses--
}
s.advanceUses(v)
continue
}
This is usually the right decision--disabling this bit of code causes an overall regression. But as the initial code shows, there are instances in which it'd be better to issue the rematerializable value right away. I'm not sure exactly what the right set of conditions is, though.
This code is a bit silly, but it's the smallest reproduction I have handy. :)
When compiled, this code tests b, and on each branch it contains an LEAQ of
type.int
. The LEAQ should be hoisted above the branch, since it is needed immediately in each case, and there are registers to spare.The CSE pass does its work, and there is a single LEAQ instruction going into regalloc. However, early in regalloc, we decide to issue it every place we need it:
This is usually the right decision--disabling this bit of code causes an overall regression. But as the initial code shows, there are instances in which it'd be better to issue the rematerializable value right away. I'm not sure exactly what the right set of conditions is, though.
cc @cherrymui @randall77
The text was updated successfully, but these errors were encountered: