[SPIRV] Add PreLegalizer pattern matching for `lerp` GL extension
Nobody has claimed this yet.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Follow-up to #213097.
Following the lerp implementation move, SPIR-V now lowers lerp as a generic fsub+fmul+fadd instead of the GL extension:
lerp(x, y, s) ->
sub = fsub y, x
mul = fmul s, sub
fadd x, mul
We can pattern match this in SPIRVCombine.td and SPIRVCombinerHelper.cpp to
fadd(
x,
fmul(s,
fsub(y, x)))
which would allow us to change fadd(x, fmul(s, fsub(y, x))) back into lerp(x, y, s) so that SPIR-V emits the GL extension again.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing patterns in SPIRVCombine.td and the matching logic in SPIRVCombinerHelper.cpp, along with the follow-up context from #213097. Implement recognition of the shown fadd/fmul/fsub shape so SPIR-V emits the lerp GL extension again; done means the generic lowering is combined back to lerp.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100