<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Alexey,<br>
<br>
I appreciate your response. My colleague and I are implementing a
transformation pass between LLVM IR and another IR and we want to
keep the 3-component vector types in our target IR. As you
mentioned, the 4-component vector type conversion code is not
problem. But I usually expect clang generates more target
independent LLVM IR except target specific properties like calling
convention, memory layout of variables, etc. clang can keep the
3-component vector type operations and llvm codegen can handle them
according to target. At present, we're having to undo Clang's
transformation of vec3 -> vec4, to recreate the original type
information, which is unfortunate. Would it be possible to add an
option to control the behaviour?<br>
<br>
Thanks,<br>
<br>
JinGu Kang<br>
<br>
<br>
<div class="moz-cite-prefix">On 07/03/17 18:19,
<a class="moz-txt-link-abbreviated" href="mailto:aleksey.bader@gmail.com">aleksey.bader@gmail.com</a> wrote:<br>
</div>
<blockquote
cite="mid:CANoB8+7-e+P0sSWdQy_0Z58QWMr43q4x-4wgEy9ekyeAhU=geA@mail.gmail.com"
type="cite">
<div dir="ltr">Hi JinGu,
<div><br>
</div>
<div>I don't think it should be a problem for OpenCL.
3-component vector is aligned as 4-component vector (see
section 6.1.5 "Alignment of Type" of OpenCL C kernel language
specification v2.0).</div>
<div>AFAIK, almost all existing OpenCL compilers are based on
clang and there seems to be no problems with handling
load/store operations this way.<br>
</div>
<div>Could you elaborate on the case where this approach doesn't
work?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Alexey</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Mar 6, 2017 at 6:47 PM, <a
moz-do-not-send="true" href="mailto:jingu@codeplay.com">jingu@codeplay.com</a>
via cfe-dev <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
<br>
I have a question about "CodeGenFunction::EmitLoadOfSc<wbr>alar".
I am compiling code with vector type of 3 elements like int3
or float3. Clang converts the vector load to different
vector load with 4 element vector type because there is code
on "CodeGenFunction::EmitLoadOfSc<wbr>alar" as follows:<br>
<br>
1312 // For better performance, handle vector loads
differently.<br>
1313 if (Ty->isVectorType()) {<br>
1314 const llvm::Type *EltTy = Addr.getElementType();<br>
1315<br>
1316 const auto *VTy =
cast<llvm::VectorType>(EltTy);<br>
1317<br>
1318 // Handle vectors of size 3 like size 4 for better
performance.<br>
1319 if (VTy->getNumElements() == 3) {<br>
1320<br>
1321 // Bitcast to vec4 type.<br>
1322 llvm::VectorType *vec4Ty =
llvm::VectorType::get(VTy->get<wbr>ElementType(),<br>
1323
4);<br>
1324 Address Cast = Builder.CreateElementBitCast(A<wbr>ddr,
vec4Ty, "castToVec4");<br>
1325 // Now load value.<br>
1326 llvm::Value *V = Builder.CreateLoad(Cast,
Volatile, "loadVec4");<br>
<br>
4 element vector load could generate aligned vector load in
the end and it would be better in usual. But it is not good
for other target or language like OpenCL which supports 3
element vector type natively. Can we consider this situation
on "CodeGenFunction::EmitLoadOfSc<wbr>alar" like this "if
(!getLangOpts().OpenCL)" or with target specific property on
TargetCodeGenInfo?<br>
<br>
If I missed something, please let me know.<br>
<br>
Thanks,<br>
JinGu Kang<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>