<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText>Hi Tim,<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>This intrinsic is legacy ARMv7:<o:p></o:p></p><p class=MsoPlainText>               int64x1_t vadd_s64(int64x1_t a, (int64x1_t b) <o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>I can generate "add d0, d1, d0" from this one using IR operations. This is not a problem.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>The ARMv8 intrinsic is:<o:p></o:p></p><p class=MsoPlainText>               int64_t vaddd_s64(int64_t a, (int64_t b)<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>I was just pointing out that if I define the ARMv8 intrinsic using the legacy ARMv7 intrinsic produces code like this:<o:p></o:p></p><p class=MsoPlainText>               (int64_t) vadd_s64((int64x1_t(a), int64x1_t(b))<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>which results in "add x0, x1, x0".<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>The same happens if I translate the ARMv8 builtin for vaddd_s64 into CreateAdd code in CGBuiltin.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>So coming from a builtin for ARMv8 ACLE scalar intrinsic it does not look like I can use the IR operations to guarantee that Scalar Neon instructions are selected. So I defined a LLVM intrinsic.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>Now we need to confirm what is the expected implementation for a Neon intrinisic - to produce only Neon code or produce best code possible?<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>The spreadsheet I have with AArch64 intrinsics definitions shows Neon instruction is expected: <o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText><o:p> </o:p></p><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=1338 style='width:803.0pt;margin-left:-.75pt;border-collapse:collapse'><tr style='height:.2in'><td width=210 nowrap valign=top style='width:1.75in;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><b><span style='color:black'>Intrinsic name<o:p></o:p></span></b></p></td><td width=190 nowrap valign=top style='width:114.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><b><span style='color:black'>Instruction Generated<o:p></o:p></span></b></p></td><td width=238 nowrap valign=top style='width:143.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><b><span style='color:black'>Operands<o:p></o:p></span></b></p></td><td width=195 nowrap valign=top style='width:117.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><b><span style='color:black'>Notes<o:p></o:p></span></b></p></td><td width=172 nowrap valign=top style='width:103.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><b><span style='color:black'>Example prototypes<o:p></o:p></span></b></p></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td></tr><tr style='height:.2in'><td width=210 nowrap valign=top style='width:1.75in;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=190 nowrap valign=top style='width:114.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=238 nowrap valign=top style='width:143.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=195 nowrap valign=top style='width:117.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=172 nowrap valign=top style='width:103.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=top style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td></tr><tr style='height:.2in'><td width=210 nowrap valign=bottom style='width:1.75in;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><b><span style='color:black'>Scalar add<o:p></o:p></span></b></p></td><td width=190 nowrap valign=bottom style='width:114.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p></td><td width=238 nowrap valign=bottom style='width:143.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='font-family:"Courier New";color:black'> <o:p></o:p></span></p></td><td width=195 nowrap valign=bottom style='width:117.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p></td><td width=172 nowrap valign=bottom style='width:103.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p></td><td width=83 nowrap valign=bottom style='width:50.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p></td><td width=83 nowrap valign=bottom style='width:50.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p></td><td width=83 nowrap valign=bottom style='width:50.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p></td><td width=83 nowrap valign=bottom style='width:50.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='color:black'> <o:p></o:p></span></p></td></tr><tr style='height:.2in'><td width=210 nowrap valign=bottom style='width:1.75in;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=190 nowrap valign=bottom style='width:114.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=238 nowrap valign=bottom style='width:143.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=195 nowrap valign=bottom style='width:117.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=172 nowrap valign=bottom style='width:103.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td></tr><tr style='height:.2in'><td width=210 nowrap valign=bottom style='width:1.75in;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal>vaddd_s64<o:p></o:p></p></td><td width=190 nowrap valign=bottom style='width:114.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='font-family:"Courier New";color:black'>ADD<o:p></o:p></span></p></td><td width=238 nowrap valign=bottom style='width:143.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='font-family:"Courier New";color:black'>Dd,Da,Db<o:p></o:p></span></p></td><td width=195 nowrap valign=bottom style='width:117.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=172 nowrap valign=bottom style='width:103.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td></tr><tr style='height:.2in'><td width=210 nowrap valign=bottom style='width:1.75in;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal>vaddd_u64<o:p></o:p></p></td><td width=190 nowrap valign=bottom style='width:114.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='font-family:"Courier New";color:black'>ADD<o:p></o:p></span></p></td><td width=238 nowrap valign=bottom style='width:143.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'><p class=MsoNormal><span style='font-family:"Courier New";color:black'>Dd,Da,Db<o:p></o:p></span></p></td><td width=195 nowrap valign=bottom style='width:117.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=172 nowrap valign=bottom style='width:103.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td><td width=83 nowrap valign=bottom style='width:50.0pt;padding:0in 5.4pt 0in 5.4pt;height:.2in'></td></tr></table><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>This is one of the side effects to using v1ix and v1fx in the backend.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>Thanks,<o:p></o:p></p><p class=MsoPlainText>Ana.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>-----Original Message-----<br>From: Tim Northover [mailto:t.p.northover@gmail.com] <br>Sent: Wednesday, September 11, 2013 7:35 AM<br>To: Ana Pazos<br>Cc: llvm-commits; cfe-commits@cs.uiuc.edu; rajav@codeaurora.org; mcrosier@codeaurora.org<br>Subject: Re: patches with initial implementation of Neon scalar instructions</p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>Hi Ana,<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>>       Because the Clang builtins use scalar types, if in CGBuiltin I <o:p></o:p></p><p class=MsoPlainText>> transform the code below into an IR operation using CreateAdd, the <o:p></o:p></p><p class=MsoPlainText>> code is optimized and results in the machine instruction ‘add X0, X1, <o:p></o:p></p><p class=MsoPlainText>> X0’, which is not what we want.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>I wonder if that's actually true. Realistically, the function you wrote *is* better implemented with "add x0, x1, x0", instead of three fmovs and an  "add d0, d1, d0".<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>If you put a call to your vaddd_s64 back into a "vector" context, where it *does* make sense to use the "add d0, d1, d0" version then I think LLVM will get it right again:<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>int64x1_t my_own_little_function(int64x1_t a, int64x1_t b) {<o:p></o:p></p><p class=MsoPlainText>  return vaddd_s64((int64_t)a, (int64_t)b); }<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>After inlining I'd expect the optimised IR to still contain an "add <1 x i64>" here and the assembly to use the "add d0, d1, d0" form (in this case faster than 3 fmovs and an "add x0, x1, x0").<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>Obviously LLVM isn't perfect at spotting these contexts yet, but I don't think we should be hobbling it by insisting on a SISD add just because that's what the intrinsic notionally maps to.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>Cheers.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>Tim.<o:p></o:p></p></div></body></html>