diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-23 16:59:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-23 16:59:02 -0700 |
| commit | 50e7d9797d9bf4b98a056d5df128c24dde6e78bd (patch) | |
| tree | 3e6e4491b1b6512280adff1d69a93ccaf50f6bb3 /source/slang/slang-ir-simplify-cfg.cpp | |
| parent | 85f005888cadeb4b1d957b57a86cbad6cc9ea313 (diff) | |
Fix optimization pass not converging. (#2725)
* Fix optimization pass not converging.
* Fix.
* Fix tests.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-simplify-cfg.cpp')
| -rw-r--r-- | source/slang/slang-ir-simplify-cfg.cpp | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/source/slang/slang-ir-simplify-cfg.cpp b/source/slang/slang-ir-simplify-cfg.cpp index e98d14a0c..4d5b6e21b 100644 --- a/source/slang/slang-ir-simplify-cfg.cpp +++ b/source/slang/slang-ir-simplify-cfg.cpp @@ -315,42 +315,6 @@ static bool isTrivialIfElse(IRIfElse* condBranch, bool& isTrueBranchTrivial, boo return false; } -#if 0 -static bool tryMoveFalseBranchToTrueBranch(IRBuilder& builder, IRIfElse* ifElseInst) -{ - auto falseBlock = ifElseInst->getFalseBlock(); - if (falseBlock == ifElseInst->getAfterBlock()) - return false; - if (auto termInst = as<IRUnconditionalBranch>(falseBlock->getTerminator())) - { - // We can't fold a branch with arguments into the ifElse. - if (termInst->getArgCount() != 0) - return false; - } - ifElseInst->trueBlock.set(falseBlock); - ifElseInst->falseBlock.set(ifElseInst->getAfterBlock()); - builder.setInsertBefore(ifElseInst); - auto newCondition = builder.emitNot(builder.getBoolType(), ifElseInst->getCondition()); - ifElseInst->condition.set(newCondition); - return true; -} -#endif - -static bool tryEliminateFalseBranch(IRIfElse* ifElseInst) -{ - auto falseBlock = ifElseInst->getFalseBlock(); - if (falseBlock == ifElseInst->getAfterBlock()) - return false; - if (auto termInst = as<IRUnconditionalBranch>(falseBlock->getTerminator())) - { - // We can't fold a branch with arguments into the ifElse. - if (termInst->getArgCount() != 0) - return false; - } - ifElseInst->falseBlock.set(ifElseInst->getAfterBlock()); - return true; -} - static bool trySimplifyIfElse(IRBuilder& builder, IRIfElse* ifElseInst) { bool isTrueBranchTrivial = false; @@ -371,18 +335,6 @@ static bool trySimplifyIfElse(IRBuilder& builder, IRIfElse* ifElseInst) return true; } } - else if (isTrueBranchTrivial) - { - // If true branch is empty, we move false branch to true branch and invert the condition. - // TODO: diabled for now since our auto-diff pass can't handle loops whose body is on the false - // side of condition. - //return tryMoveFalseBranchToTrueBranch(builder, ifElseInst); - } - else if (isFalseBranchTrivial) - { - // If false branch is empty, we set it to afterBlock. - return tryEliminateFalseBranch(ifElseInst); - } return false; } |
