Skip to content

Commit

Permalink
Address code review feedback
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
zeux committed Jan 13, 2025
1 parent 07578df commit 9641df9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CodeGen/src/IrLoweringA64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion CodeGen/src/IrLoweringX64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion CodeGen/src/IrTranslateBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 9641df9

Please sign in to comment.