From 0c778339d7e3c39f600af2cc049f13f661d3434b Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:24:46 -0700 Subject: Relax the inst definition order rule (#8588) Close #8572. The root cause of the issue is that in `_replaceInstUsesWith` call, if the use of the inst is a generic parameter, and the inst is the data type of that generic parameter, we could end up of moving the data type before the generic parameter. This will break the layout of generic parameters, where all the generic parameters should be laid consecutively at the beginning of the first block of the generic. Therefore, we don't make that relocation for such case. --- source/slang/slang-ir-validate.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir-validate.cpp') diff --git a/source/slang/slang-ir-validate.cpp b/source/slang/slang-ir-validate.cpp index 55f3ad227..e7bb7b548 100644 --- a/source/slang/slang-ir-validate.cpp +++ b/source/slang/slang-ir-validate.cpp @@ -201,9 +201,13 @@ void validateIRInstOperand(IRValidateContext* context, IRInst* inst, IRUse* oper // in order. if (context) { + // There is exception that the use of an inst is defined before the inst, + // e.g. generic parameter can be defined before its data type in some cases. + // In those cases we allow relaxing the rule. validate( context, - context->seenInsts.contains(operandValue), + context->seenInsts.contains(operandValue) || + canRelaxInstOrderRule(operandValue, inst), inst, "def must come before use in same block"); } -- cgit v1.2.3