Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wazevo(arm64): fixes lowerVMinMaxPseudo #1836

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions internal/engine/wazevo/backend/isa/arm64/lower_instr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,15 +1108,9 @@ func (m *machine) lowerVMinMaxPseudo(instr *ssa.Instruction, max bool) {

rn := m.getOperand_NR(m.compiler.ValueDefinition(x), extModeNone)
rm := m.getOperand_NR(m.compiler.ValueDefinition(y), extModeNone)
creg := m.getOperand_NR(m.compiler.ValueDefinition(instr.Return()), extModeNone)
tmp := operandNR(m.compiler.AllocateVReg(ssa.TypeV128))

// creg is overwritten by BSL, so we need to move it to the result register before the instruction
// in case when it is used somewhere else.
rd := m.compiler.VRegOf(instr.Return())
mov := m.allocateInstr()
mov.asFpuMov128(tmp.nr(), creg.nr())
m.insert(mov)
// TODO: this usage of tmp is weird - it should be fine directly using rd. (seems a bug in regalloc).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fixed in the linear regalloc

tmp := operandNR(m.compiler.AllocateVReg(ssa.TypeV128))

fcmgt := m.allocateInstr()
if max {
Expand All @@ -1131,8 +1125,9 @@ func (m *machine) lowerVMinMaxPseudo(instr *ssa.Instruction, max bool) {
bsl.asVecRRR(vecOpBsl, tmp, rm, rn, vecArrangement16B)
m.insert(bsl)

res := operandNR(m.compiler.VRegOf(instr.Return()))
mov2 := m.allocateInstr()
mov2.asFpuMov128(rd, tmp.nr())
mov2.asFpuMov128(res.nr(), tmp.nr())
m.insert(mov2)
}

Expand Down
Loading