summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-09-22 00:42:17 +0800
committerGitHub <noreply@github.com>2023-09-21 09:42:17 -0700
commit4810dbd49067c5dc03ffeb9f580b83146f66326a (patch)
treea2161c7bd5960c5d64c4c553fa39660b99904b1b /source/slang/slang-ir.cpp
parent65e1a5be6d2c1a470df93eff5dd8cd04589485da (diff)
Do not move movable insts in fuse-satcoop (#3221)
* Do not move movable insts in fuse-satcoop * Add case for IRCall in isMovableInst --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index b4a8e6f42..95d6c9e1f 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -8132,6 +8132,99 @@ namespace Slang
return static_cast<IRDominatorTree*>(domTree.get());
}
+ bool isMovableInst(IRInst* inst)
+ {
+ // Don't try to modify hoistable insts, they are already globally deduplicated.
+ if (getIROpInfo(inst->getOp()).isHoistable())
+ return false;
+
+ switch (inst->getOp())
+ {
+ case kIROp_Add:
+ case kIROp_Sub:
+ case kIROp_Mul:
+ case kIROp_FRem:
+ case kIROp_IRem:
+ case kIROp_Lsh:
+ case kIROp_Rsh:
+ case kIROp_And:
+ case kIROp_Or:
+ case kIROp_Not:
+ case kIROp_Neg:
+ case kIROp_FieldExtract:
+ case kIROp_FieldAddress:
+ case kIROp_GetElement:
+ case kIROp_GetElementPtr:
+ case kIROp_UpdateElement:
+ case kIROp_Specialize:
+ case kIROp_LookupWitness:
+ case kIROp_OptionalHasValue:
+ case kIROp_GetOptionalValue:
+ case kIROp_MakeOptionalValue:
+ case kIROp_MakeTuple:
+ case kIROp_GetTupleElement:
+ case kIROp_MakeStruct:
+ case kIROp_MakeArray:
+ case kIROp_MakeArrayFromElement:
+ case kIROp_MakeVector:
+ case kIROp_MakeMatrix:
+ case kIROp_MakeMatrixFromScalar:
+ case kIROp_MakeVectorFromScalar:
+ case kIROp_swizzle:
+ case kIROp_swizzleSet:
+ case kIROp_MatrixReshape:
+ case kIROp_MakeString:
+ case kIROp_MakeResultError:
+ case kIROp_MakeResultValue:
+ case kIROp_GetResultError:
+ case kIROp_GetResultValue:
+ case kIROp_CastFloatToInt:
+ case kIROp_CastIntToFloat:
+ case kIROp_CastIntToPtr:
+ case kIROp_CastPtrToBool:
+ case kIROp_CastPtrToInt:
+ case kIROp_BitAnd:
+ case kIROp_BitNot:
+ case kIROp_BitOr:
+ case kIROp_BitXor:
+ case kIROp_BitCast:
+ case kIROp_IntCast:
+ case kIROp_FloatCast:
+ case kIROp_Reinterpret:
+ case kIROp_Greater:
+ case kIROp_Less:
+ case kIROp_Geq:
+ case kIROp_Leq:
+ case kIROp_Neq:
+ case kIROp_Eql:
+ case kIROp_ExtractExistentialType:
+ case kIROp_ExtractExistentialValue:
+ case kIROp_ExtractExistentialWitnessTable:
+ return true;
+ case kIROp_Call:
+ // Similar to the case in IRInst::mightHaveSideEffects, pure
+ // calls are ok
+ return isSideEffectFreeFunctionalCall(cast<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;
+ }
+ }
+
} // namespace Slang
#if SLANG_VC