summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-util.cpp
diff options
context:
space:
mode:
authorJerran Schmidt <jerranschmidt@gmail.com>2025-06-17 13:49:02 +1000
committerGitHub <noreply@github.com>2025-06-16 20:49:02 -0700
commit60a8f1fc3eee37977ee891661f65916f66aef364 (patch)
tree7c6b93260a4b1b672876769717984b587965a17d /source/slang/slang-ir-util.cpp
parenta4345725a083651c16795d27fedd769f2d7e55ae (diff)
Fix for missing signedness cast in SwizzleIR (#7448)
* Cast if there is a signedness mismatch on the swizzle * Move isSignedType to slang-util and add test --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
-rw-r--r--source/slang/slang-ir-util.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index 13742711c..a2ec15661 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -2348,4 +2348,25 @@ bool isInstHoistable(IROp op, IRType* type, IRInst* const* fixedArgs)
isSpecConstOpHoistable(op, type, fixedArgs);
}
+bool isSignedType(IRType* type)
+{
+ switch (type->getOp())
+ {
+ case kIROp_FloatType:
+ case kIROp_DoubleType:
+ return true;
+ case kIROp_IntType:
+ case kIROp_Int16Type:
+ case kIROp_Int64Type:
+ case kIROp_Int8Type:
+ return true;
+ case kIROp_VectorType:
+ return isSignedType(as<IRVectorType>(type)->getElementType());
+ case kIROp_MatrixType:
+ return isSignedType(as<IRMatrixType>(type)->getElementType());
+ default:
+ return false;
+ }
+}
+
} // namespace Slang