소스 검색

Mark precise on dxil operations when set Gis. (#2861)

* Mark precise on dxil operations when set Gis.
Xiang Li 5 년 전
부모
커밋
1aae3a5eec
2개의 변경된 파일25개의 추가작업 그리고 2개의 파일을 삭제
  1. 17 2
      lib/HLSL/DxilGenerationPass.cpp
  2. 8 0
      tools/clang/test/HLSLFileCheck/hlsl/compile_options/gis_dxil_op.hlsl

+ 17 - 2
lib/HLSL/DxilGenerationPass.cpp

@@ -651,9 +651,24 @@ static void TranslatePreciseAttributeOnFunction(Function &F, Module &M) {
 
 void DxilGenerationPass::TranslatePreciseAttribute() {  
   bool bIEEEStrict = m_pHLModule->GetHLOptions().bIEEEStrict;
-  // If IEEE strict, everying is precise, don't need to mark it.
-  if (bIEEEStrict)
+  if (bIEEEStrict) {
+    // mark precise on dxil operations.
+    Module &M = *m_pHLModule->GetModule();
+    for (Function &F : M) {
+      if (!hlsl::OP::IsDxilOpFunc(&F))
+        continue;
+      if (!F.getReturnType()->isFPOrFPVectorTy())
+        continue;
+      for (User *U : F.users()) {
+        Instruction *I = dyn_cast<Instruction>(U);
+        if (!I)
+          continue;
+        IRBuilder<> B(I);
+        HLModule::MarkPreciseAttributeOnValWithFunctionCall(I, B, M);
+      }
+    }
     return;
+  }
 
   Module &M = *m_pHLModule->GetModule();
   // TODO: If not inline every function, for function has call site with precise

+ 8 - 0
tools/clang/test/HLSLFileCheck/hlsl/compile_options/gis_dxil_op.hlsl

@@ -0,0 +1,8 @@
+// RUN: %dxc -E main -T ps_6_0 -Gis %s | FileCheck %s
+
+// Make sure mark precise on dxil operations when set Gis.
+// CHECK:dx.precise
+
+float main(float2 a:A) : SV_Target {
+  return dot(a,a);
+}