Open sooknarine opened 1 year ago
Here's a compiler explorer link for the described behavior: https://godbolt.org/z/x5aP3b41T
This no longer repros on recent compilers.
Actually the previous godbolt link was bad. This one shows a repro: https://godbolt.org/z/x8er4WYeE
Compiling i33.hlsl.txt with
-T lib_6_3 i33.hlsl -Fc i33.dxil.txt
shows a zext of i32 to i33. The DXIL spec only mentions support for integer types “i1, i8, i16, i32, i64”.Relevant snippet from i33.dxil.txt:
Tested on December 2022 and October 2020 releases.
The i33 type is added by the Scalar Evolution pass - this is a standard LLVM pass that is used to optimize loop control expressions. Where possible it replaces the loop control expression with a constant or a simpler expression which replaces the loop, or at least reduces the number of iterations. The expression used is ((input - 1) * (input - 2)) / 2 and the extension to i33 is to allow for the possibility of the multiplication resulting in overflow - the division by 2 guarantees the final result fits in i32.