diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-27 15:18:07 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-27 15:18:07 -0800 |
| commit | a3ba22b51c371d5a20d61aa4e35233ba4f4f68db (patch) | |
| tree | 704f8e9575fdd888d01137054b4c3887aaac9360 /source/slang/slang-ir-redundancy-removal.cpp | |
| parent | b1b76f06ca5bdfc4b688d99095dfb7d561a04d80 (diff) | |
Detect and deduplicate read-only resource access. (#2680)
* Detect and deduplicate read-only resource access.
* Fix tests.
* Fix tests.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-redundancy-removal.cpp')
| -rw-r--r-- | source/slang/slang-ir-redundancy-removal.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang-ir-redundancy-removal.cpp b/source/slang/slang-ir-redundancy-removal.cpp index 2a2047de9..32b349a4f 100644 --- a/source/slang/slang-ir-redundancy-removal.cpp +++ b/source/slang/slang-ir-redundancy-removal.cpp @@ -28,6 +28,8 @@ struct RedundancyRemovalContext case kIROp_GetElement: case kIROp_GetElementPtr: case kIROp_UpdateElement: + case kIROp_Specialize: + case kIROp_LookupWitness: case kIROp_OptionalHasValue: case kIROp_GetOptionalValue: case kIROp_MakeOptionalValue: @@ -67,6 +69,21 @@ struct RedundancyRemovalContext return true; case kIROp_Call: return isPureFunctionalCall(as<IRCall>(inst)); + case kIROp_Load: + // Load is generally not movable, an exception is loading a global constant buffer. + if (auto load = as<IRLoad>(inst)) + { + auto addrType = load->getPtr()->getDataType(); + switch (addrType->getOp()) + { + case kIROp_ConstantBufferType: + case kIROp_ParameterBlockType: + return true; + default: + break; + } + } + return false; default: return false; } |
