[cfe-dev] [OpenCL] allow __builtin_astype(char4, char3)

Anastasia Stulova via cfe-dev cfe-dev at lists.llvm.org
Mon May 9 11:03:22 PDT 2016


Hi Sam,

I think it makes sense considering that it's quite common to use __builtin_astype for implementing OpenCL as_type.

Cheers,
Anastasia

From: Liu, Yaxun (Sam) [mailto:Yaxun.Liu at amd.com]
Sent: 06 May 2016 21:53
To: cfe-dev (cfe-dev at lists.llvm.org); Anastasia Stulova; Pan, Xiuli
Subject: [OpenCL] allow __builtin_astype(char4, char3)

Is char3 as_char3(char4 x) a valid OpenCL builtin function?

According to the spec, both have 4 bytes, so it seems to be a valid builtin.

Naturally one would want to implement it as

char3 as_char3(char4 x) { return __builtin_astype(x, char3); }

However this does not work since Clang will generate bitcast <4 x i8> to <3 x i8> and this is an invalid llvm instruction.

Do you think Clang should be patched to generate correct llvm instruction for this case?

Thanks.

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160509/85d1394b/attachment.html>


More information about the cfe-dev mailing list