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

CodeGen: Implement support for math.lerp lowering #1609

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Address code review feedback
- A64 can reuse any of a/b/c/d for output register
- X64 can reuse c/d for output register; only b can't be reused because
  it might be clobbered when a is loaded from memory
- Remove unused condition argument from SELECT_NUM as we assume == for now
zeux committed Jan 13, 2025
commit 9641df963340c6596301d84b8319da703b1c5fd9
2 changes: 1 addition & 1 deletion CodeGen/src/IrLoweringA64.cpp
Original file line number Diff line number Diff line change
@@ -707,7 +707,7 @@ void IrLoweringA64::lowerInst(IrInst& inst, uint32_t index, const IrBlock& next)
case IrCmd::SELECT_NUM:
{
LUAU_ASSERT(FFlag::LuauCodeGenLerp);
inst.regA64 = regs.allocReuse(KindA64::d, index, {inst.a, inst.b});
inst.regA64 = regs.allocReuse(KindA64::d, index, {inst.a, inst.b, inst.c, inst.d});

RegisterA64 temp1 = tempDouble(inst.a);
RegisterA64 temp2 = tempDouble(inst.b);
2 changes: 1 addition & 1 deletion CodeGen/src/IrLoweringX64.cpp
Original file line number Diff line number Diff line change
@@ -626,7 +626,7 @@ void IrLoweringX64::lowerInst(IrInst& inst, uint32_t index, const IrBlock& next)
case IrCmd::SELECT_NUM:
{
LUAU_ASSERT(FFlag::LuauCodeGenLerp);
inst.regX64 = regs.allocRegOrReuse(SizeX64::xmmword, index, {inst.a}); // can't reuse b if a is a memory operand
inst.regX64 = regs.allocRegOrReuse(SizeX64::xmmword, index, {inst.a, inst.c, inst.d}); // can't reuse b if a is a memory operand

ScopedRegX64 tmp{regs, SizeX64::xmmword};

2 changes: 1 addition & 1 deletion CodeGen/src/IrTranslateBuiltins.cpp
Original file line number Diff line number Diff line change
@@ -311,7 +311,7 @@ static BuiltinImplResult translateBuiltinMathLerp(
IrOp t = builtinLoadDouble(build, arg3);

IrOp l = build.inst(IrCmd::ADD_NUM, a, build.inst(IrCmd::MUL_NUM, build.inst(IrCmd::SUB_NUM, b, a), t));
IrOp r = build.inst(IrCmd::SELECT_NUM, l, b, t, build.constDouble(1.0), build.cond(IrCondition::Equal));
IrOp r = build.inst(IrCmd::SELECT_NUM, l, b, t, build.constDouble(1.0)); // select on t==1.0

build.inst(IrCmd::STORE_DOUBLE, build.vmReg(ra), r);