Compiling the function below currently produces a register spill:
package p
type T [100]int
func f(p *T) {
if g() {
h(0, *p)
} else {
g()
h(1, *p)
}
}
func g() bool
func h(int, T)
This is because h(1, *p) is compiled to OINDREGSP(8) = *p, which is represented in SSA as Move(OffPtr(8, SP), p).
OffPtr(8, SP) is trivially rematerialized on x86 with LEA $8(SP), but we're currently lowering OffPtr to ADDQconst, which is marked as non-rematerializeable because it clobbers flags (unlike LEAQ).
Distilled from #22558.
/cc @randall77
Compiling the function below currently produces a register spill:
This is because
h(1, *p)is compiled toOINDREGSP(8) = *p, which is represented in SSA asMove(OffPtr(8, SP), p).OffPtr(8, SP)is trivially rematerialized on x86 withLEA $8(SP), but we're currently loweringOffPtrtoADDQconst, which is marked as non-rematerializeable because it clobbers flags (unlike LEAQ).Distilled from #22558.
/cc @randall77