summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-ssa-simplification.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-02-24 10:01:47 -0800
committerGitHub <noreply@github.com>2023-02-24 10:01:47 -0800
commitbd6306cdaa4a49344658bd026721b6532e103d09 (patch)
treebb7f666d426e6cfc7777a3ccac0a1d628588eb39 /source/slang/slang-ir-ssa-simplification.cpp
parente8c08e7ecb1124f115a1d1042277776193122b57 (diff)
More control flow simplifications. (#2673)
* More control flow and Phi param simplifications. * Fix. * Fix gcc error. * Fix. * More IR cleanup. * Fix bug in phi param dce + ifelse simplify. * Propagate and DCE side-effect-free functions. * Enhance CFG simplifcation to remove loops with no side effects. * Fix. * Fixes. * Fix tests. Add [__AlwaysFoldIntoUseSite] for rayPayloadLocation. * More cleanup. * Fixes. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-ssa-simplification.cpp')
-rw-r--r--source/slang/slang-ir-ssa-simplification.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/slang/slang-ir-ssa-simplification.cpp b/source/slang/slang-ir-ssa-simplification.cpp
index f06fafcb3..beaaae065 100644
--- a/source/slang/slang-ir-ssa-simplification.cpp
+++ b/source/slang/slang-ir-ssa-simplification.cpp
@@ -10,6 +10,7 @@
#include "slang-ir-deduplicate-generic-children.h"
#include "slang-ir-remove-unused-generic-param.h"
#include "slang-ir-redundancy-removal.h"
+#include "slang-ir-propagate-func-properties.h"
namespace Slang
{
@@ -29,6 +30,7 @@ namespace Slang
changed |= peepholeOptimize(module);
changed |= removeRedundancy(module);
changed |= simplifyCFG(module);
+ changed |= propagateFuncProperties(module);
// Note: we disregard the `changed` state from dead code elimination pass since
// SCCP pass could be generating temporarily evaluated constant values and never actually use them.
@@ -41,6 +43,28 @@ namespace Slang
}
}
+ void simplifyNonSSAIR(IRModule* module)
+ {
+ bool changed = true;
+ const int kMaxIterations = 8;
+ int iterationCounter = 0;
+ while (changed && iterationCounter < kMaxIterations)
+ {
+ changed = false;
+ changed |= peepholeOptimize(module);
+ changed |= removeRedundancy(module);
+ changed |= simplifyCFG(module);
+
+ // Note: we disregard the `changed` state from dead code elimination pass since
+ // SCCP pass could be generating temporarily evaluated constant values and never actually use them.
+ // DCE will always remove those nearly generated consts and always returns true here.
+ eliminateDeadCode(module);
+
+ iterationCounter++;
+ }
+ }
+
+
void simplifyFunc(IRGlobalValueWithCode* func)
{
bool changed = true;