<div dir="ltr">Dear all,<div><br></div><div>I am using LLVM C++ API to generate some code. In particular, I am dealing with AVX2 SIMD API which uses __m256i.</div><div><br></div><div>My function input types a set of vectors and return type is also a vector.</div><div><br></div><div>///////////////////////////////////////////////////////////////////////////////////////////</div><div><div>                arguments.push_back(VectorType::get(IntegerType::getIntNTy(TheContext, 64), 4));//int64*4 = __m256i</div><div>                FunctionType * proto = FunctionType::get(VectorType::get(IntegerType::getIntNTy(TheContext, 64), 4),//int64*4 = __m256i<br></div><div>                                                         arguments, false);</div></div><div>

<div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br class="gmail-Apple-interchange-newline">

</div>I can successfully use this way to produce the IR of my function properly like this:</div><div>

<div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div><div style="text-decoration-style:initial;text-decoration-color:initial">










<p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">define <4 x i64> @tpchq6(<4 x i64> %leaf7, <4 x i64> %leaf8, <4 x i64> %leaf9, <4 x i64> %leaf10, <4 x i64> %leaf11, <4 x i64> %leaf12, <4 x i64> %leaf13, <4 x i64> %leaf14) {</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">entry:</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  %addtmp = add <4 x i64> %leaf14, %leaf13</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  %leaf8.neg = sub <4 x i64> zeroinitializer, %leaf8</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  %xortmp = xor <4 x i64> %addtmp, %leaf11</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  %addtmp1 = add <4 x i64> %leaf8.neg, %leaf7</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  %subtmp = add <4 x i64> %addtmp1, %leaf9</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  %addtmp2 = add <4 x i64> %subtmp, %leaf10</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  %addtmp3 = add <4 x i64> %addtmp2, %xortmp</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">  ret <4 x i64> %addtmp3</span></font></p><p style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font color="#000000" face="Arial"><span style="font-size:16px">}</span></font></p>





<br class="gmail-Apple-interchange-newline">

</div>

<div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div><div><br></div>However, when I use JIT ExectionEngine to run it, it cannot return the Vector type properly. I tried the jit execution engine with non-vector return like int64, it works fine.</div><div><br></div><div>My code is as follows: It always tells me segment fault</div><div>

<div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255)">///////////////////////////////////////////////////////////////////////////////////////////</div>

<div>// Define the input/output data type in LLVM function</div><div> typedef std::vector<int64_t> VecInt;</div></div><div><br></div><div><div>auto function = reinterpret_cast<VecInt (*)(VecInt , VecInt, VecInt, VecInt, VecInt, VecInt, VecInt, VecInt)>(TheExecutionEngine->getFunctionAddress(TheFunction->getName().str()));</div><div>VecInt result = function(functionCallArgs[0],functionCallArgs[1],functionCallArgs[2],functionCallArgs[3],</div><div>                            functionCallArgs[4],functionCallArgs[5],functionCallArgs[6],functionCallArgs[7]);</div></div><div><br></div><div>std::cout<<"result size "<<

<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">result</span>.size()<<"\n";<br></div><div>

<div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div><div style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br class="gmail-Apple-interchange-newline">

</div><br class="gmail-Apple-interchange-newline">

Can someone tell me whether this is the correct way to retrieve the vector return type? Or is the vector type return supported?</div><div><br></div><div>Thanks,</div><div>Jia Yu<br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p style="margin:0in 0in 0.0001pt"><br></p><div style="line-height:21px"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>