llvm / llvm/llvm-project

[SPIRV] Add PreLegalizer pattern matching for `radians` GL extension

Open
#214,880 0 comments 0 reactions 0 assignees View on GitHub
backend:SPIR-V
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Follow-up to #213095.

Following the `radians` implementation move, SPIR-V now lowers `radians` as a generic `fmul` instead of the GL extension:
```asm
radians(x) ->
fmul x, (pi / 180)
```
We can pattern match this in `SPIRVCombine.td` and `SPIRVCombinerHelper.cpp` to
```llvm
fmul(
x,
(pi / 180))
```
which would allow us to change `fmul(x, pi/180)` back into `radians(x)` so that SPIR-V emits the GL extension again.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing radians lowering and the related pattern-matching code in SPIRVCombine.td and SPIRVCombinerHelper.cpp, with follow-up issue #213095 as context. Verify that the fmul form using pi / 180 is recognized and that SPIR-V emits the radians GL extension again.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.