KhronosGroup / KhronosGroup/SPIRV-Tools
spirv-opt: missed optimization opportunity for VectorShuffle over CompositeConstruct
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
The following pattern is currently not optimized by spirv-opt with either `-O` or `-Os`
```
%10 =
%11 = OpCompositeExtract %int %10 0
%12 = OpCompositeExtract %int %10 1
%13 = OpCompositeConstruct %v3int %11 %12 %int_0
%14 = OpVectorShuffle %v2int %13 %13 0 1
```
I think this should be simplified to:
```
%10 =
%14 = %10
```
Contributor guide
Research direction
Start in the spirv-opt optimization paths exercised by -O and -Os, and locate handling for VectorShuffle together with CompositeConstruct. Reproduce the shown instruction pattern, then verify that both optimization modes reduce it to the original vector; add or run a regression test covering the transformation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100