-
Notifications
You must be signed in to change notification settings - Fork 664
spirv-opt: Loop unroller doesn't support OpConstantNull #3634
Description
If you try to execute spirv-opt <attached file> -o out.spv --loop-unroll on the attached file, the tool will crash. The reason is that LoopUnroller optimization pass doesn't support OpConstantNull instructions.
Note that the attached file demonstrates the case when the initial value of the counter
is an OpConstantNull. The same bug can be observed if we try to use OpConstantNull to limit the number of iterations or as a step of an iteration (ids %7, %13, %21 in the attached file).
The code that causes these crashes is as follows.
SPIRV-Tools/source/opt/loop_descriptor.cpp
Lines 687 to 688 in b78f4b1
| const analysis::Integer* type = | |
| upper_bound->AsIntConstant()->type()->AsInteger(); |
SPIRV-Tools/source/opt/loop_descriptor.cpp
Lines 712 to 713 in b78f4b1
| const analysis::Integer* step_type = | |
| step_constant->AsIntConstant()->type()->AsInteger(); |
SPIRV-Tools/source/opt/loop_descriptor.cpp
Lines 194 to 195 in b78f4b1
| const analysis::Integer* type = | |
| constant->AsIntConstant()->type()->AsInteger(); |
Can be reproduced on b78f4b1.