diff --git a/lib/HLSL/HLModule.cpp b/lib/HLSL/HLModule.cpp index 01f559f86..0393a6dba 100644 --- a/lib/HLSL/HLModule.cpp +++ b/lib/HLSL/HLModule.cpp @@ -1099,8 +1099,13 @@ void HLModule::MarkPreciseAttributeOnPtrWithFunctionCall(llvm::Value *Ptr, MarkPreciseAttributeOnValWithFunctionCall(arg, Builder, M); } } else { - IRBuilder<> Builder(CI->getNextNode()); - MarkPreciseAttributeOnValWithFunctionCall(CI, Builder, M); + if (CI->getType()->isPointerTy()) { + // For instance, matrix subscript... + MarkPreciseAttributeOnPtrWithFunctionCall(CI, M); + } else { + IRBuilder<> Builder(CI->getNextNode()); + MarkPreciseAttributeOnValWithFunctionCall(CI, Builder, M); + } } } else { // Must be GEP here. diff --git a/tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/precise/precise-matrix-subscript.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/precise/precise-matrix-subscript.hlsl new file mode 100644 index 000000000..ce93dab28 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/hlsl/types/modifiers/precise/precise-matrix-subscript.hlsl @@ -0,0 +1,12 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// CHECK: define void @main() + +float3x3 main(float3 normal : IN) : OUT +{ + precise float3x3 ret; // <---- precise + ret[0] = normal; + ret[1] = normal; + ret[2] = normal; + return ret; +}