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.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.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 206d73e3f..69870c128 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -7093,8 +7093,6 @@ namespace Slang case kIROp_Add: case kIROp_Sub: case kIROp_Mul: - //case kIROp_Div: // TODO: We could split out integer vs. floating-point div/mod and assume the floating-point cases have no side effects - //case kIROp_Rem: case kIROp_Lsh: case kIROp_Rsh: case kIROp_Eql: @@ -7138,6 +7136,22 @@ namespace Slang case kIROp_BackwardDifferentiatePropagate: case kIROp_DetachDerivative: return false; + + case kIROp_Div: + case kIROp_IRem: + if (isIntegralScalarOrCompositeType(getFullType())) + { + if (auto intLit = as<IRIntLit>(getOperand(1))) + { + if (intLit->getValue() != 0) + return false; + } + return true; + } + return false; + + case kIROp_FRem: + return false; } return true; } |
