summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-peephole.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-04 21:57:50 -0800
committerGitHub <noreply@github.com>2024-03-04 21:57:50 -0800
commitbb017e6aa8ddbfac6b9a78a66f4706964fbeaff4 (patch)
treee902a0c319a326a035f815e6ac16a3d19fc860d3 /source/slang/slang-ir-peephole.cpp
parent2297623aad4c249bccae3fe363ada31e308131ac (diff)
Extend `as` and `is` operator to work on generic types. (#3672)
Diffstat (limited to 'source/slang/slang-ir-peephole.cpp')
-rw-r--r--source/slang/slang-ir-peephole.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp
index d7c3c6bda..d4369da7a 100644
--- a/source/slang/slang-ir-peephole.cpp
+++ b/source/slang/slang-ir-peephole.cpp
@@ -958,8 +958,14 @@ struct PeepholeContext : InstPassBase
}
case kIROp_TypeEquals:
{
- auto left = inst->getOperand(0)->getDataType();
- auto right = inst->getOperand(1)->getDataType();
+ auto getTypeFromOperand = [](IRInst* operand) -> IRType*
+ {
+ if (as<IRTypeType>(operand->getFullType()) || !operand->getFullType())
+ return (IRType*)operand;
+ return operand->getFullType();
+ };
+ auto left = getTypeFromOperand(inst->getOperand(0));
+ auto right = getTypeFromOperand(inst->getOperand(1));
if (isConcreteType(left) && isConcreteType(right))
{
IRBuilder builder(module);