diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-08-17 14:45:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-17 14:45:13 -0400 |
| commit | 945409c4c6871c18aad24086c594cc66b5913733 (patch) | |
| tree | 41eed63f115971d82875e23acbec77d78be4cf3a /source/slang/slang-ir-ssa.cpp | |
| parent | 216fc18661fd6e05053b4cc864396e6017e85b04 (diff) | |
Initial support for differentiating existential types (#3111)
* Merge
* WIP: Complete auto-diff logic for existential types
* Revert "Add compiler option for generating representative hash"
This reverts commit 13b09ef4621e73844c96d64d9c111a8ed0d45aae.
* More fixes for fwd-mode AD on existential types
* Add anyValueSize inference pass
* Fix checking of `Differential.Differential==Differential`
* In-progress: infer any-value-size for existential types
* Existentials now work in forward-mode
* Overhaul handling of existential AD types. Fwd-mode works, reverse-mode requires front-end changes
* Reverse-mode now works on existentials
* Cleanup
* Remove diff rules for create existential object for now
* Revert treat-as-differentiable changes
* Fixes
* More fixes
* Cleanup
* more cleanup
* signed/unsigned
* Revert "Cleanup"
This reverts commit e4f7d71f07bb207736f90708961eeecd09a1b652.
* Cleanup (again)
* Remove public/export/keep-alive on null differential after AD pass
* Minor fix
* Update dictionary accessors
* Keep export decoration
* More fixes + Support for `kIROp_PackAnyValue`
* Merge upstream
* Update expected-failure.txt
Diffstat (limited to 'source/slang/slang-ir-ssa.cpp')
| -rw-r--r-- | source/slang/slang-ir-ssa.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index 18eba677e..730943bf8 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -412,7 +412,7 @@ PhiInfo* addPhi( { valueType = context->getBuilder()->getRateQualifiedType(rate, valueType); } - IRParam* phi = builder->createParam(valueType); + IRParam* phi = builder->emitParam(valueType); cloneRelevantDecorations(var, phi); RefPtr<PhiInfo> phiInfo = new PhiInfo(); @@ -503,6 +503,7 @@ IRInst* tryRemoveTrivialPhi( // replace uses of the phi (including its possible uses // of itself) with the unique non-phi value. phi->replaceUsesWith(same); + phi->removeAndDeallocate(); // Clear out the operands to the phi, since they won't // actually get used in the program any more. @@ -849,11 +850,12 @@ void processBlock( // leave them as-is, or replace them with a value // that we look up with local/global value numbering - IRInst* next = nullptr; - for (auto ii = block->getFirstInst(); ii; ii = next) - { - next = ii->getNextInst(); + List<IRInst*> workList; + for (auto ii = block->getFirstInst(); ii; ii = ii->getNextInst()) + workList.add(ii); + for (auto& ii : workList) + { // Any new instructions we create to represent // the new value will get inserted before whatever // instruction we are working with. @@ -1117,6 +1119,14 @@ bool constructSSA(ConstructSSAContext* context) { auto blockInfo = *context->blockInfos.tryGetValue(bb); + // First remove phis from their parent blocks. + for (auto phiInfo : blockInfo->phis) + if (!phiInfo->replacement) + phiInfo->phi->removeFromParent(); + + // Then, add them back in a consistent order, and add predecessor + // args in the same order. + // for (auto phiInfo : blockInfo->phis) { // If we replaced this phi with another value, |
