luau/CodeGen/include/Luau
Arseny Kapoulkine 24cacc94ed
Some checks are pending
benchmark / callgrind (map[branch:main name:luau-lang/benchmark-data], ubuntu-22.04) (push) Waiting to run
build / macos (push) Waiting to run
build / macos-arm (push) Waiting to run
build / ubuntu (push) Waiting to run
build / windows (Win32) (push) Waiting to run
build / windows (x64) (push) Waiting to run
build / coverage (push) Waiting to run
build / web (push) Waiting to run
release / macos (push) Waiting to run
release / ubuntu (push) Waiting to run
release / windows (push) Waiting to run
release / web (push) Waiting to run
CodeGen: Implement support for math.lerp lowering (#1609)
To implement math.lerp without branches, we add SELECT_NUM which
selects one of the two inputs based on the comparison condition.

For simplicity, we only support C == D for now; this can be extended to
a more generic version with a IrCondition operand E, but that requires
more work on the SSE side (to flip the comparison for some conditions
like Greater, and expose more generic vcmpsd).

Note: On AArch64 this will effectively result in a change in floating
point
behavior between native code and non-native code: clang synthesizes
fmadd (because floating point contraction is allowed by default, and the
arch always has the instruction), whereas this change will use
fmul+fadd.

I am not sure if this is good or bad, and if this is a problem in C or
not.
Specifically, clang's behavior results in different results between X64
and AArch64 when *not* using codegen, and with this change the behavior
when using codegen is... the same? :)

Fixing this will require either using LERP_NUM instead and hand-coding
lowering, or exposing some sort of "quasi" MADD_NUM (which would
lower to fma on AArch64 and mul+add on X64).

A small benefit to the current approach is `lerp(1, 5, t)`
constant-folds the
subtraction. With LERP_NUM this optimization will need to be implemented
manually as a partial constant-folding for LERP_NUM.

A similar problem exists today for vector.cross & vector.dot. So maybe
this
is not something we need to fix, unsure.
2025-01-16 10:48:27 -08:00
..
AddressA64.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00
AssemblyBuilderA64.h CodeGen: Rewrite dot product lowering using a dedicated IR instruction (#1512) 2024-11-08 16:23:09 -08:00
AssemblyBuilderX64.h CodeGen: Implement support for math.lerp lowering (#1609) 2025-01-16 10:48:27 -08:00
BytecodeAnalysis.h Sync to upstream/release/625 (#1252) 2024-05-10 11:21:45 -07:00
BytecodeSummary.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00
CodeAllocator.h Sync to upstream/release/637 (#1354) 2024-08-02 07:30:04 -07:00
CodeBlockUnwind.h Sync to upstream/release/576 (#928) 2023-05-12 10:50:47 -07:00
CodeGen.h Sync to upstream/release/637 (#1354) 2024-08-02 07:30:04 -07:00
CodeGenCommon.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00
ConditionA64.h Sync to upstream/release/573 (#903) 2023-04-21 15:14:26 -07:00
ConditionX64.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00
IrAnalysis.h Sync to upstream/release/637 (#1354) 2024-08-02 07:30:04 -07:00
IrBuilder.h Sync to upstream/release/630 (#1295) 2024-06-14 13:21:20 -07:00
IrCallWrapperX64.h Sync to upstream/release/572 (#899) 2023-04-14 11:06:22 -07:00
IrData.h CodeGen: Implement support for math.lerp lowering (#1609) 2025-01-16 10:48:27 -08:00
IrDump.h Sync to upstream/release/656 (#1612) 2025-01-10 11:34:39 -08:00
IrRegAllocX64.h Sync to upstream/release/596 (#1050) 2023-09-22 12:12:15 -07:00
IrUtils.h CodeGen: Implement support for math.lerp lowering (#1609) 2025-01-16 10:48:27 -08:00
IrVisitUseDef.h Sync to upstream/release/640 (#1374) 2024-08-23 09:35:30 -07:00
Label.h Sync to upstream/release/529 (#505) 2022-05-26 15:08:16 -07:00
NativeProtoExecData.h Sync to upstream/release/620 (#1223) 2024-04-05 13:45:09 -07:00
OperandX64.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00
OptimizeConstProp.h Sync to upstream/release/574 (#910) 2023-04-28 12:55:13 -07:00
OptimizeDeadStore.h Sync to upstream/release/616 (#1184) 2024-03-08 16:47:53 -08:00
OptimizeFinalX64.h Sync to upstream/release/563 (#833) 2023-02-10 11:40:38 -08:00
RegisterA64.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00
RegisterX64.h Sync to upstream/release/613 (#1167) 2024-02-15 18:04:39 -08:00
SharedCodeAllocator.h Sync to upstream/release/637 (#1354) 2024-08-02 07:30:04 -07:00
UnwindBuilder.h Sync to upstream/release/637 (#1354) 2024-08-02 07:30:04 -07:00
UnwindBuilderDwarf2.h Sync to upstream/release/637 (#1354) 2024-08-02 07:30:04 -07:00
UnwindBuilderWin.h Sync to upstream/release/637 (#1354) 2024-08-02 07:30:04 -07:00