KhronosGroup / KhronosGroup/SPIRV-Tools

[spirv-reduce] Potential reduction opportunities

Open
#2,178 1 comment 0 reactions 0 assignees View on GitHub
component:reducer
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

I recently tried to reducer. It did a very good job of removing code inside the functions. However, it left a really big header. In the zip file, I have the original spv, the result of the reducer, and the full hand reduced spir-v assembly: [t.tar.gz](https://github.com/KhronosGroup/SPIRV-Tools/files/2653796/t.tar.gz)

The steps that I had to do by hand were:

- [ ] Remove unused input and output variables `%2 %3 %4 %5 %gl_VertexIndex %gl_InstanceIndex`.
- [ ] Remove unused constants. `%uint_2147483647` and others are not used.
- [ ] Remove unsued types like `%_ptr_Input__arr_v4float_uint_3` and some of the other pointer types.
- [ ] Merge types (that is replace all floats by ints, or all ints by bools) to reduce the number of types used.
- [ ] Remove unused functions. (`%88` is never called)
- [ ] Remove unused parameters from functions. `%92` is not used. Need to change the call sights and function types.
- [ ] Remove unused return values from functions. `%86` is never used, so change the function `%87` to have a void return type. Lots of coordinated change need to happen to keep this correct.

Contributor guide

Open the contributing guide

Research direction

Start with the spirv-reduce entry point and reproduce the attached t.tar.gz case using the original, reduced, and hand-reduced SPIR-V files. Review how reduction opportunities are currently handled, then scope and validate unused declarations, type merging, unused functions, and function signature changes with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.