[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-11 Thread Chris B via cfe-commits
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-10 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-10 Thread Chris B via cfe-commits
llvm-beanz wrote: > ExprConstant.cpp currently assumes that an CK_HLSLVectorTruncation can't > return a scalar type. Thank you for catching this! I've updated the PR and included a test that constant evaluates some vector truncations in static asserts. https://github.com/llvm/llvm-project/pul

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-10 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/104844 >From 1a1a92aff834aa2f6f12d3de001714d8338dd274 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Tue, 13 Aug 2024 15:51:34 -0500 Subject: [PATCH 1/4] [HLSL] Allow truncation to scalar HLSL allows implicit

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-09 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: ExprConstant.cpp currently assumes that an CK_HLSLVectorTruncation can't return a scalar type. https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-09 Thread Chris B via cfe-commits
@@ -4828,18 +4830,23 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } case ICK_HLSL_Vector_Truncation: { // Note: HLSL built-in vectors are ExtVectors. Since this truncates a - // vector to a smaller vector, this can only operate on argument

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-09 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/104844 >From 1a1a92aff834aa2f6f12d3de001714d8338dd274 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Tue, 13 Aug 2024 15:51:34 -0500 Subject: [PATCH 1/3] [HLSL] Allow truncation to scalar HLSL allows implicit

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-09 Thread Chris B via cfe-commits
@@ -2032,26 +2032,42 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, if (S.Context.hasSameUnqualifiedType(FromType, ToType)) return false; + // HLSL allows implicit truncation of vector types. + if (S.getLangOpts().HLSL) { +auto *ToE

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner approved this pull request. Just a few style nitpicks. LG! https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -4828,18 +4830,23 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } case ICK_HLSL_Vector_Truncation: { // Note: HLSL built-in vectors are ExtVectors. Since this truncates a - // vector to a smaller vector, this can only operate on argument

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
https://github.com/bogner edited https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -2032,26 +2032,42 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, if (S.Context.hasSameUnqualifiedType(FromType, ToType)) return false; + // HLSL allows implicit truncation of vector types. + if (S.getLangOpts().HLSL) { +auto *ToE

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Justin Bogner via cfe-commits
@@ -2692,14 +2692,19 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { return CGF.CGM.createOpenCLIntToSamplerConversion(E, CGF); case CK_HLSLVectorTruncation: { -assert(DestTy->isVectorType() && "Expected dest type to be vector type"); +assert((DestTy->

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-06 Thread Chris B via cfe-commits
@@ -673,9 +673,6 @@ float dot(float3, float3); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot) float dot(float4, float4); -_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot) -double dot(double, double); - llvm-beanz wrote: Oh, I think this can stay in once this PR lands: https

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-30 Thread Chris B via cfe-commits
@@ -143,19 +143,3 @@ float test_dot_float3(float3 p0, float3 p1) { return dot(p0, p1); } // CHECK: %dx.dot = call float @llvm.dx.dot4.v4f32(<4 x float> %0, <4 x float> %1) // CHECK: ret float %dx.dot float test_dot_float4(float4 p0, float4 p1) { return dot(p0, p1); } - -// CH

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-30 Thread Damyan Pepper via cfe-commits
@@ -143,19 +143,3 @@ float test_dot_float3(float3 p0, float3 p1) { return dot(p0, p1); } // CHECK: %dx.dot = call float @llvm.dx.dot4.v4f32(<4 x float> %0, <4 x float> %1) // CHECK: ret float %dx.dot float test_dot_float4(float4 p0, float4 p1) { return dot(p0, p1); } - -// CH

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-30 Thread Damyan Pepper via cfe-commits
@@ -673,9 +673,6 @@ float dot(float3, float3); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot) float dot(float4, float4); -_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot) -double dot(double, double); - damyanp wrote: Surprised to see this here based on the description. Wonde

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-30 Thread Damyan Pepper via cfe-commits
https://github.com/damyanp approved this pull request. https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-19 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Chris B (llvm-beanz) Changes HLSL allows implicit conversions to truncate vectors to scalar pr-values. These conversions are scored as vector truncations and should warn appropriately. This change allows forming a truncation cast to

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-19 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Chris B (llvm-beanz) Changes HLSL allows implicit conversions to truncate vectors to scalar pr-values. These conversions are scored as vector truncations and should warn appropriately. This change allows forming a truncation cast to a pr-

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-19 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-hlsl @llvm/pr-subscribers-clang-codegen Author: Chris B (llvm-beanz) Changes HLSL allows implicit conversions to truncate vectors to scalar pr-values. These conversions are scored as vector truncations and should warn appropriately. This change allows

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-19 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/104844 HLSL allows implicit conversions to truncate vectors to scalar pr-values. These conversions are scored as vector truncations and should warn appropriately. This change allows forming a truncation cast to a p