DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
Move HLSL shift behavior to frontend
The HLSL bit shift behavior was implemented in constant folding which alters the semantics of the IR. Alternatively we can implement it in the front end, leveraging the existing OpenCL code paths.
This results in the same final IR optimization and allows reverting the ConstantFolder and IR tests back to match LLVM 3.7.
The HLSL shift behavior's optimized behavior is verified in existing tests like the shift-fold.hlsl test, which is unimpacted by this change.
The big motiviation for this change is heading off subtle bugs. All our tests cover cases where the shift's size is known at compile time. In those cases the compiler can resolve the masking behavior automatically. We have no tests, nor compiler changes that impact shifts that aren't compile-time known.
This means that prior to this change the behavior of shifting by a compile-time resolvable value and shifting by a non-resolvable value likely differs. Since backends often load DXIL and treat it as LLVM IR, this could cause concerning issues.
:white_check_mark: Build DirectXShaderCompiler 1.0.1983 completed (commit https://github.com/microsoft/DirectXShaderCompiler/commit/4033992b5e by @llvm-beanz)
:white_check_mark: Build DirectXShaderCompiler 1.0.1984 completed (commit https://github.com/microsoft/DirectXShaderCompiler/commit/6d5f2fcc65 by @llvm-beanz)
Did you shift the 'f' in the title in the spirit of the functionality involved? 😉
:white_check_mark: Build DirectXShaderCompiler 1.0.1987 completed (commit https://github.com/microsoft/DirectXShaderCompiler/commit/0b6a7efd0f by @llvm-beanz)