Author: Xiang Li Date: 2022-09-09T10:55:45-07:00 New Revision: c9d2b6b92d6c29d00f6adc0527cf2331dbaae31a
URL: https://github.com/llvm/llvm-project/commit/c9d2b6b92d6c29d00f6adc0527cf2331dbaae31a DIFF: https://github.com/llvm/llvm-project/commit/c9d2b6b92d6c29d00f6adc0527cf2331dbaae31a.diff LOG: [HLSL] Preserve vec3 for HLSL. Preserve vec3 for HLSL by set -fpreserve-vec3-type. Reviewed By: beanz Differential Revision: https://reviews.llvm.org/D132913 Added: clang/test/CodeGenHLSL/float3.hlsl Modified: clang/include/clang/Driver/Options.td Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index b9be33396fdfe..d6a4ad40f5020 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6170,7 +6170,8 @@ def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">, def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, HelpText<"Preserve 3-component vector type">, - MarshallingInfoFlag<CodeGenOpts<"PreserveVec3Type">>; + MarshallingInfoFlag<CodeGenOpts<"PreserveVec3Type">>, + ImpliedByAnyOf<[hlsl.KeyPath]>; def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">, diff --git a/clang/test/CodeGenHLSL/float3.hlsl b/clang/test/CodeGenHLSL/float3.hlsl new file mode 100644 index 0000000000000..6ee43157cecec --- /dev/null +++ b/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; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits