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

Liu, Yaxun (Sam) via cfe-dev cfe-dev at lists.llvm.org
Tue May 10 10:38:29 PDT 2016


Actually the codegen can generate correct llvm IR for __builtin_astype(char4, char3), but not for __builtin_astype(int, char3) and other types. I will try to fix that.

Thanks.

Sam

From: Anastasia Stulova [mailto:Anastasia.Stulova at arm.com]
Sent: Monday, May 9, 2016 2:03 PM
To: Liu, Yaxun (Sam) <Yaxun.Liu at amd.com>; cfe-dev (cfe-dev at lists.llvm.org) <cfe-dev at lists.llvm.org>; Pan, Xiuli <xiuli.pan at intel.com>
Cc: nd <nd at arm.com>
Subject: RE: [OpenCL] allow __builtin_astype(char4, char3)

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<mailto: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/20160510/0064c600/attachment.html>


More information about the cfe-dev mailing list