[libclc] [libclc] Move degrees/radians to CLC library & optimize (PR #123222)

2025-01-17 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/123222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move degrees/radians to CLC library & optimize (PR #123222)

2025-01-16 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: I wasn't able to verify the `half` variants with the OpenCL CTS for some obscure CTS reason. Given that they're just casting the double literal to half I think they're almost certainly correct. https://github.com/llvm/llvm-project/pull/123222

[libclc] [libclc] Move degrees/radians to CLC library & optimize (PR #123222)

2025-01-16 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/123222 Missing half variants were also added. The builtins are now consistently emitted in vector form (i.e., with a splat of the literal to the appropriate vector size). >From abe207cb6b90597a4f90a1db922c63ceb97

[libclc] [libclc] Move smoothstep to CLC and optimize its codegen (PR #123183)

2025-01-16 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/123183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move smoothstep to CLC and optimize its codegen (PR #123183)

2025-01-16 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,52 @@ +/* frasercrmck wrote: I wasn't sure if the AMD copyright still applies to this copied file, so I kept it. https://github.com/llvm/llvm-project/pull/123183 ___ cfe-commits mailing list cfe-commits@lis

[libclc] [libclc] Move smoothstep to CLC and optimize its codegen (PR #123183)

2025-01-16 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: Here's an example of the difference in LLVM IR for `smoothstep(double16, double16, double16)`: https://godbolt.org/z/P9sM3Wjjn https://github.com/llvm/llvm-project/pull/123183 ___ cfe-commits mailing list cfe-commits@lists.llvm.or

[libclc] [libclc] Move smoothstep to CLC and optimize its codegen (PR #123183)

2025-01-16 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/123183 This commit moves the implementation of the smoothstep function to the CLC library, whilst optimizing the codegen. This commit also adds support for 'half' versions of smoothstep, which were previously mis

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2025-01-15 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: ping https://github.com/llvm/llvm-project/pull/116786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Add missing includes to CLC headers (PR #118654)

2025-01-15 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/118654 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move fp16 pragma guards out of header file (PR #122751)

2025-01-14 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/122751 >From 4dd89f2be8e80797a8e921145339ac2716505830 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 13 Jan 2025 17:29:06 + Subject: [PATCH 1/2] [libclc] Move fp16 pragma guards out of header file Ha

[libclc] [libclc] Move fp16 pragma guards out of header file (PR #122751)

2025-01-14 Thread Fraser Cormack via cfe-commits
@@ -207,10 +207,6 @@ return BUILTIN(x); \ } -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - #define _CLC_DEFINE_UNARY_BUILTIN_FP16(FUNCTION) \ _CLC_DEF _CLC

[libclc] [libclc] Move fp16 pragma guards out of header file (PR #122751)

2025-01-14 Thread Fraser Cormack via cfe-commits
@@ -207,10 +207,6 @@ return BUILTIN(x); \ } -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - #define _CLC_DEFINE_UNARY_BUILTIN_FP16(FUNCTION) \ _CLC_DEF _CLC

[libclc] [libclc] Move fp16 pragma guards out of header file (PR #122751)

2025-01-13 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/122751 Having the fp16 pragmas enabled in the header file is risky, as we have some headers that also disable pragmas. We want to be as immune to changes in the order of included header files as possible. This pa

[clang] [llvm] [BasicAA] Do not decompose past casts with different index width (PR #119365)

2025-01-09 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > @frasercrmck BasicAA returns MayAlias for your example. Presumably AMDGPUAA > returns NoAlias because addrspace(3) and addrspace(0) can't alias, or > something like that. Yep, you're right, sorry for the false alarm. Because it's a `amdgpu_kernel` function and `A` (`%incd

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-09 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-09 Thread Fraser Cormack via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-09 Thread Fraser Cormack via cfe-commits
@@ -14604,57 +14611,63 @@ bool Sema::PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall) { } bool Sema::BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly) { - QualType Res; - if (BuiltinVectorMath(TheCall, Res, FPOnly)) -return true; - TheCall->setType(Res);

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-09 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/8] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-07 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/7] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-07 Thread Fraser Cormack via cfe-commits
@@ -14604,57 +14611,63 @@ bool Sema::PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall) { } bool Sema::BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly) { - QualType Res; - if (BuiltinVectorMath(TheCall, Res, FPOnly)) -return true; - TheCall->setType(Res);

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-07 Thread Fraser Cormack via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -649,7 +649,9 @@ Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±in The integer elementwise intrinsics, including ``__builtin_elementwise_popcount``, ``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``, -``__builtin_elementwis

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/6] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > Would be good to also update the documentation for the builtins the clarify > the behavior. I've added some words to that effect. Is that what you had in mind? https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mail

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/5] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -68,15 +66,18 @@ void test_builtin_elementwise_add_sat(float f1, float f2, double d1, double d2, long long int i2, si8 vi1, si8 vi2, unsigned u1, unsigned u2, u4 vu1, u4 vu2,

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/4] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2024-12-18 Thread Fraser Cormack via cfe-commits
@@ -6,7 +6,7 @@ // CHECK: %conv2 = fptrunc double %hlsl.dot to float // CHECK: ret float %conv2 float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) { - return __builtin_hlsl_dot ( p0, p1 ); + return __builtin_hlsl_dot ( (double)p0, (double)p1 );

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2024-12-18 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2024-12-18 Thread Fraser Cormack via cfe-commits
@@ -68,15 +66,18 @@ void test_builtin_elementwise_add_sat(float f1, float f2, double d1, double d2, long long int i2, si8 vi1, si8 vi2, unsigned u1, unsigned u2, u4 vu1, u4 vu2,

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2024-12-18 Thread Fraser Cormack via cfe-commits
@@ -6,7 +6,7 @@ // CHECK: %conv2 = fptrunc double %hlsl.dot to float // CHECK: ret float %conv2 float builtin_bool_to_float_type_promotion ( float p0, bool p1 ) { - return __builtin_hlsl_dot ( p0, p1 ); + return __builtin_hlsl_dot ( (double)p0, (double)p1 );

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2024-12-18 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix sub-integer __builtin_elementwise_(add|sub)_sat (PR #119423)

2024-12-18 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 30b30fd3c74e41363984ae1055470b9e37d3ee20 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/3] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Fix sub-integer __builtin_elementwise_(add|sub)_sat (PR #119423)

2024-12-18 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: RFC: https://discourse.llvm.org/t/rfc-change-behaviour-of-elementwise-builtins-on-scalar-integer-types/83725. I don't expect anyone to say anything at all, tbh, especially during the holidays. > If people aren't using the edge cases, they won't notice if we start > error'i

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-17 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: @arsenm are you happy for this to be merged? https://github.com/llvm/llvm-project/pull/116786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-17 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/116786 >From 65713ca581a83261e888feb7a96c76d1525d223b Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 17 Dec 2024 16:52:51 + Subject: [PATCH] [libclc] Move several integer functions to CLC library Thi

[libclc] [libclc] Optimize ceil/fabs/floor/rint/trunc (PR #119596)

2024-12-13 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/119596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Optimize ceil/fabs/floor/rint/trunc (PR #119596)

2024-12-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/119596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Optimize ceil/fabs/floor/rint/trunc (PR #119596)

2024-12-12 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > > which in its header uses this strange **asm** method of calling LLVM > > intrinsics directly. > > That's something that's always surprised me it works. It's rather unsafe (you > can bypass immarg validation for instance). Plus asm callsites get infected > with overly co

[libclc] [libclc] Optimize ceil/fabs/floor/rint/trunc (PR #119596)

2024-12-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119596 >From 68df2622a3ca1b98a0cbf1fc9e6200e12fecbb2e Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 11 Dec 2024 17:28:38 + Subject: [PATCH 1/2] [libclc] Optimize ceil/fabs/floor/rint/trunc These fun

[libclc] [libclc] Optimize ceil/fabs/floor/rint/trunc (PR #119596)

2024-12-12 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > LGTM. I'm not sure how this all ends up expanding, I was expecting to see the > elementwise builtins used. Yes, I suspect that this code originates from before the builtins were available? The builtins would probably make more sense, tbh. The current method is that we hav

[clang] [clang] Fix sub-integer __builtin_elementwise_(add|sub)_sat (PR #119423)

2024-12-12 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > Even with this fix, the behavior with mixed types still seems really > confusing, especially if you mix signed/unsigned inputs. Can we address that > somehow? I totally agree. The (elementwise) builtins won't let you mix `ext_vector_type`s of different signs or element s

[libclc] [libclc] Optimize ceil/fabs/floor/rint/trunc (PR #119596)

2024-12-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: CC @rjodinchr, @karolherbst https://github.com/llvm/llvm-project/pull/119596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Optimize ceil/fabs/floor/rint/trunc (PR #119596)

2024-12-11 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/119596 These functions all map to the corresponding LLVM intrinsics, but the vector intrinsics weren't being generated. The intrinsic mapping from CLC vector function to vector intrinsic was working correctly, but

[clang] [clang] Fix sub-integer __builtin_elementwise_(add|sub)_sat (PR #119423)

2024-12-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > I thought bitreverse/popcount are only supposed to work with unsigned types? Good question. The [documentation](https://clang.llvm.org/docs/LanguageExtensions.html) doesn't mention they're only for signed types, as `abs` does, for example. So if there is such a restrictio

[clang] [clang] Fix sub-integer __builtin_elementwise_(add|sub)_sat (PR #119423)

2024-12-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: I just realised this is also a problem with the `bitreverse` and `popcount` builtins on signed types for the same reason. https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https

[clang] [clang] Fix sub-integer __builtin_elementwise_(add|sub)_sat (PR #119423)

2024-12-10 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/119423 These builtins would unconditionally perform the usual arithmetic conversions on promotable scalar integer arguments. This meant in practice that char and short arguments were promoted to int, and the opera

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-09 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > > In this conte

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-05 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > On the `clspv`

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-05 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > > I'm not sure

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/116786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-04 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > > The clspv/spi

[libclc] [libclc] Add missing includes to CLC headers (PR #118654)

2024-12-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/118654 There's no automatic way of checking these headers are self-contained. Instead of including these common files many times across the whole codebase, we can include them in the generic `gentype.inc` and `flo

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-04 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,44 @@ +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF char __clc_clz(char x) { + return __clc_clz((ushort)(uchar)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF uchar __clc_clz(uchar x) { + return __clc_clz((ushort)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF short __clc_clz(

[libclc] [libcxx] [llvm] [openmp] [polly] [llvm] Move sub-project lead maintainers into their own Maintainers.md files (PR #118309)

2024-12-03 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > For libclc maybe @tstellar -> @frasercrmck (or maybe both). I'm not opposed to this if people think it suitable. But having someone from Red Hat or AMD as co-maintainer(s) makes sense to me, as it's a project used (downstream) by several different groups. https://github.

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-25 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: Oh right, I thoug

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-25 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,38 @@ +#include +#include +#include + +#define CLC_SIGN(TYPE, F) \ + _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) { \ +if (__clc_isnan(x)) {

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/115699 >From 0a9bcdc5fb9da8ada6d2580026f498f282ca7cf7 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 7 Nov 2024 12:40:56 + Subject: [PATCH] [libclc] Move sign to the CLC builtins library This patch n

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV ) - set( opt_flags ) + set( clc_opt_flags ) + # Inline CLC functions into OpenCL

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/115699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV ) - set( opt_flags ) + set( clc_opt_flags ) + # Inline CLC functions into OpenCL

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-19 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,44 @@ +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF char __clc_clz(char x) { + return __clc_clz((ushort)(uchar)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF uchar __clc_clz(uchar x) { + return __clc_clz((ushort)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF short __clc_clz(

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-19 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/116786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-19 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/116786 This commit moves over the OpenCL clz, hadd, mad24, mad_hi, mul24, mul_hi, popcount, rhadd, and upsample builtins to the CLC library. There are no changes to any target's CLC libraries. The OpenCL mad_hi b

[libclc] [libclc] Create aliases with custom_command (PR #115885)

2024-11-13 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: Relanded in #116025. https://github.com/llvm/llvm-project/pull/115885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Create aliases with custom_command (PR #115885)

2024-11-13 Thread Fraser Cormack via cfe-commits
@@ -355,11 +355,13 @@ function(add_libclc_builtin_set) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) foreach( a ${ARG_ALIASES} ) set( alias_suffix "${a}-${ARG_TRIPLE}.bc" ) -add_custom_target( ${alias_suffix}

[libclc] Reland "[libclc] Create aliases with custom_command (#115885)" (PR #116025)

2024-11-13 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/116025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] Reland "[libclc] Create aliases with custom_command (#115885)" (PR #116025)

2024-11-13 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/116025 This relands commit 2c980310f67c13dd89c8702d40abeab47a4a2b4b after fixing an issue. >From beb58052420070d392f97bfba6af6af818df9a16 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 13 Nov 2024 10:38

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,38 @@ +#include +#include +#include + +#define CLC_SIGN(TYPE, F) \ + _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) { \ +if (__clc_isnan(x)) {

[libclc] [libclc] Use builtin_convertvector to convert between vector types (PR #115865)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/115865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/115699 >From 47512ee4162318160964f1af132be90bed67c90c Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 7 Nov 2024 12:40:56 + Subject: [PATCH 1/2] [libclc] Move sign to the CLC builtins library This pat

[libclc] [libclc] Use builtin_convertvector to convert between vector types (PR #115865)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/115865 This keeps values in vectors, rather than scalarizing them and then reconstituting the vector. The builtin is identical to performing a C-style cast on each element, which is what we were doing by recursive

[libclc] [libclc] Avoid using undefined vector3 components (PR #115857)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/115857 Using '.hi' on a vector3 is technically allowed by the spec and is treated as a 4-element vector with an "undefined" w component. However, it's more undef/poison code for the compiler to process and remove.

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,38 @@ +#include +#include +#include + +#define CLC_SIGN(TYPE, F) \ + _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) { \ +if (__clc_isnan(x)) {

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV ) - set( opt_flags ) + set( clc_opt_flags ) + # Inline CLC functions into OpenCL

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > > So is the sign function currently implemented in the OpenCL headers? > > The sign function for SPIR-V/Mesa is currently implemented by libclc > [here](https://github.com/llvm/llvm-project/blob/main/libclc/generic/lib/common/sign.cl). > With this change, `sign` now calls

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/115699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > So is the sign function currently implemented in the OpenCL headers? The sign function for SPIR-V/Mesa is currently implemented by libclc [here](https://github.com/llvm/llvm-project/blob/main/libclc/generic/lib/common/sign.cl). With this change, `sign` now calls `__clc_sig

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: CC @tstellar @fooishbar who might be able to account for the Mesa/SPIR-V target? https://github.com/llvm/llvm-project/pull/115699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/115699 This patch necessitates some changes to how CLSPV and SPIR-V targets are built. This is the first patch in this series in which an OpenCL function declaration has been called from the CLC library for these

[libclc] 6ca50a2 - [libclc] Correct use of CLC macro on two definitions

2024-11-07 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-07T17:47:52Z New Revision: 6ca50a2593641f45b5310d907e6323f5eb367dfa URL: https://github.com/llvm/llvm-project/commit/6ca50a2593641f45b5310d907e6323f5eb367dfa DIFF: https://github.com/llvm/llvm-project/commit/6ca50a2593641f45b5310d907e6323f5eb367dfa.diff LOG

[libclc] [libclc] Move relational functions to the CLC library (PR #115171)

2024-11-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/115171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move clcmacro.h to CLC library. NFC (PR #114845)

2024-11-04 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: Sorry for the noise, but this felt too big to just push. It should hopefully minimize diffs in upcoming patches. https://github.com/llvm/llvm-project/pull/114845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[libclc] [libclc] Move clcmacro.h to CLC library. NFC (PR #114845)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/114845 None >From e2ac0ddbd762774282e878e043bac0edbbe75407 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 4 Nov 2024 14:35:59 + Subject: [PATCH] [libclc] Move clcmacro.h to CLC library. NFC --- lib

[libclc] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library (PR #114774)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/114774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] b4ef43f - [libclc] Format clc_fma.cl. NFC

2024-11-04 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-04T11:55:42Z New Revision: b4ef43fc75dfeea76d4d968553858b2820420e58 URL: https://github.com/llvm/llvm-project/commit/b4ef43fc75dfeea76d4d968553858b2820420e58 DIFF: https://github.com/llvm/llvm-project/commit/b4ef43fc75dfeea76d4d968553858b2820420e58.diff LOG

[libclc] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library (PR #114774)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114774 >From 625b491279f81dc9b55e80bf422d0e15f44f02bb Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 31 Oct 2024 13:11:00 + Subject: [PATCH] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library Th

[libclc] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library (PR #114774)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/114774 These functions are all mapped to LLVM intrinsics. The clspv and spirv targets don't declare or define any of these CLC functions, and instead map these to their corresponding OpenCL symbols. >From 8dd4fb4

[libclc] e28d7f7 - [libclc] Format clc_tan.cl. NFC

2024-11-04 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-04T10:52:46Z New Revision: e28d7f713471cf33908a0fe5223f480dfd9b06f0 URL: https://github.com/llvm/llvm-project/commit/e28d7f713471cf33908a0fe5223f480dfd9b06f0 DIFF: https://github.com/llvm/llvm-project/commit/e28d7f713471cf33908a0fe5223f480dfd9b06f0.diff LOG

[libclc] f1888e4 - [libclc] Add some include guards and format a file

2024-11-04 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-04T10:37:11Z New Revision: f1888e4029ec2bf657a072518dcc1c9b461559be URL: https://github.com/llvm/llvm-project/commit/f1888e4029ec2bf657a072518dcc1c9b461559be DIFF: https://github.com/llvm/llvm-project/commit/f1888e4029ec2bf657a072518dcc1c9b461559be.diff LOG

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck reopened https://github.com/llvm/llvm-project/pull/114386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/114386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > Moving them seems fine but these should probably just be deleted. __clc_min > is equivalent to __builtin_elementwise_min etc. > > I see there's a __builtin_hlsl_elementwise_clamp, but given the language > prefix it may be more abusive https://github.com/llvm/llvm-projec

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,11 @@ +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, + __CLC_GENTYPE b) { + return (a > b ? a : b); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, +

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114386 >From 0465b89a7b624b8015e27efdbaf948c4aadd0e94 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 26 Sep 2024 08:57:15 +0100 Subject: [PATCH] [libclc] Move min/max/clamp into the CLC builtins library

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114386 >From c0e8cf9ec8a3ce75b62afdcbb6383af16c2f3539 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 26 Sep 2024 08:57:15 +0100 Subject: [PATCH] [libclc] Move min/max/clamp into the CLC builtins library

[libclc] fba9f05 - [libclc] Format clc_ldexp.cl and clc_hypot.cl. NFC

2024-10-31 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-10-31T10:18:29Z New Revision: fba9f05ff7b36f9cbb5835d79f659290dadecaad URL: https://github.com/llvm/llvm-project/commit/fba9f05ff7b36f9cbb5835d79f659290dadecaad DIFF: https://github.com/llvm/llvm-project/commit/fba9f05ff7b36f9cbb5835d79f659290dadecaad.diff LOG

  1   2   3   >