Skip to content

[SPIRV] Add PreLegalizer pattern matching for faceforward GL extension #137255

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

Open
kmpeng opened this issue Apr 24, 2025 · 0 comments · May be fixed by #139959
Open

[SPIRV] Add PreLegalizer pattern matching for faceforward GL extension #137255

kmpeng opened this issue Apr 24, 2025 · 0 comments · May be fixed by #139959
Assignees

Comments

@kmpeng
Copy link
Contributor

kmpeng commented Apr 24, 2025

Follow up to #99114.

The codegen for faceforward looks something like

faceforward(p1, p2, p3) ->
  dResult       = dot(p2, p3)
  cmpResult  = fcmp dResult, 0.0
  subResult   = fsub -0.0 p1
  select(cmpResult, p1, subResult)

which means we can pattern match in SPIRVCombine.td and SPIRVPreLegalizerCombiner.cpp to

select(
    fcmp(
        dot(p2, p3), 
        0),
    p1,
    0 - p1) 

This would allow us to change select(fcmp(dot(p2, p3), 0), p1, 0 - p1) to faceforward(p1, p2, p3) so that we use the right SPIR-V extension function.

@kmpeng kmpeng self-assigned this Apr 24, 2025
@kmpeng kmpeng moved this to Planning in HLSL Support Apr 24, 2025
@damyanp damyanp moved this from Planning to Active in HLSL Support Apr 28, 2025
@kmpeng kmpeng changed the title [SPIRV] Add PreLegalizer instCombine for faceforward GL extension [SPIRV] Add PreLegalizer pattern matching for faceforward GL extension May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Active
Development

Successfully merging a pull request may close this issue.

2 participants