python3kgae created this revision.
python3kgae added reviewers: bogner, beanz, pow2clk.
Herald added a subscriber: Anastasia.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Preserve vec3 for HLSL by set -fpreserve-vec3-type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132913

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenHLSL/float3.hlsl


Index: clang/test/CodeGenHLSL/float3.hlsl
===================================================================
--- /dev/null
+++ clang/test/CodeGenHLSL/float3.hlsl
@@ -0,0 +1,11 @@
+// RUN: %clang --driver-mode=dxc -Tlib_6_7 -fcgl  -Fo - %s | FileCheck %s
+
+// Make sure float3 is not changed into float4.
+// CHECK:<3 x float> @"?foo@@YAT?$__vector@M$02@__clang@@T12@@Z"(<3 x float> 
noundef %a)
+// CHECK:%[[A_ADDR:.+]] = alloca <3 x float>, align 16
+// CHECK-NEXT:store <3 x float> %a, ptr %[[A_ADDR]], align 16
+// CHECK-NEXT:%[[V:[0-9]+]] = load <3 x float>, ptr %[[A_ADDR]], align 16
+// CHECK-NEXT:ret <3 x float> %[[V]]
+float3 foo(float3 a) {
+  return a;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3520,6 +3520,8 @@
   // Add the default headers if dxc_no_stdinc is not set.
   if (!Args.hasArg(options::OPT_dxc_no_stdinc))
     CmdArgs.push_back("-finclude-default-header");
+  // Preserve vec3 for HLSL.
+  CmdArgs.push_back("-fpreserve-vec3-type");
 }
 
 static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args,


Index: clang/test/CodeGenHLSL/float3.hlsl
===================================================================
--- /dev/null
+++ clang/test/CodeGenHLSL/float3.hlsl
@@ -0,0 +1,11 @@
+// RUN: %clang --driver-mode=dxc -Tlib_6_7 -fcgl  -Fo - %s | FileCheck %s
+
+// Make sure float3 is not changed into float4.
+// CHECK:<3 x float> @"?foo@@YAT?$__vector@M$02@__clang@@T12@@Z"(<3 x float> noundef %a)
+// CHECK:%[[A_ADDR:.+]] = alloca <3 x float>, align 16
+// CHECK-NEXT:store <3 x float> %a, ptr %[[A_ADDR]], align 16
+// CHECK-NEXT:%[[V:[0-9]+]] = load <3 x float>, ptr %[[A_ADDR]], align 16
+// CHECK-NEXT:ret <3 x float> %[[V]]
+float3 foo(float3 a) {
+  return a;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3520,6 +3520,8 @@
   // Add the default headers if dxc_no_stdinc is not set.
   if (!Args.hasArg(options::OPT_dxc_no_stdinc))
     CmdArgs.push_back("-finclude-default-header");
+  // Preserve vec3 for HLSL.
+  CmdArgs.push_back("-fpreserve-vec3-type");
 }
 
 static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to