<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: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;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.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=MsoNormal>In looking at the code in ARMConstantislandPass.cpp::optimizeThumb2JumpTables(), I see that there is the following condition for not creating tbb-based jump tables:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-family:"Courier New";color:#4F6228;mso-style-textfill-fill-color:#4F6228;mso-style-textfill-fill-alpha:100.0%'> // The instruction should be a tLEApcrel or t2LEApcrelJT; we want<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New";color:#4F6228;mso-style-textfill-fill-color:#4F6228;mso-style-textfill-fill-alpha:100.0%'> // to delete it as well.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> <b><span style='color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>MachineInstr</span></b><span style='color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'> </span>*LeaMI = PrevI;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> <b><span style='color:#E46C0A;mso-style-textfill-fill-color:#E46C0A;mso-style-textfill-fill-alpha:100.0%'>if</span></b><span style='color:#E46C0A;mso-style-textfill-fill-color:#E46C0A;mso-style-textfill-fill-alpha:100.0%'> </span>((LeaMI->getOpcode() != <b><span style='color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>ARM</span></b>::tLEApcrelJT &&<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> LeaMI->getOpcode() != <b><span style='color:#984807;mso-style-textfill-fill-color:#984807;mso-style-textfill-fill-alpha:100.0%'>ARM</span></b>::t2LEApcrelJT) ||<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> LeaMI->getOperand(<span style='color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%'>0</span>).getReg() != BaseReg)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> OptOk = <b><span style='color:#E46C0A;mso-style-textfill-fill-color:#E46C0A;mso-style-textfill-fill-alpha:100.0%'>false</span></b>;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> <b><span style='color:#E46C0A;mso-style-textfill-fill-color:#E46C0A;mso-style-textfill-fill-alpha:100.0%'>if</span></b><span style='color:#E46C0A;mso-style-textfill-fill-color:#E46C0A;mso-style-textfill-fill-alpha:100.0%'> </span>(!OptOk)<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Courier New"'> <b><span style='color:#E46C0A;mso-style-textfill-fill-color:#E46C0A;mso-style-textfill-fill-alpha:100.0%'>continue</span></b>;<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I am trying to figure out why the restriction of LeaMI->getOperand(0).getReg() != BaseReg is there. It seems this is overly restrictive. For example, here is a case where it succeeds:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>8944B BB#53: derived from LLVM BB %172<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Live Ins: %R4 %R6 %D8 %Q5 %R9 %R7 %R8 %R10 %R5 %R11<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Predecessors according to CFG: BB#52<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>8976B %R1<def> = t2LEApcrelJT <jt#2>, 2, pred:14, pred:%noreg<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>8992B %R1<def> = t2ADDrs %R1<kill>, %R10, 18, pred:14, pred:%noreg, opt:%noreg<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>9004B %LR<def> = t2MOVi 1, pred:14, pred:%noreg, opt:%noreg<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>9008B t2BR_JT %R1<kill>, %R10<kill>, <jt#2>, 2<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>Shrink JT: t2BR_JT %R1<kill>, %R10<kill>, <jt#2>, 2<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> addr: %R1<def> = t2ADDrs %R1<kill>, %R10, 18, pred:14, pred:%noreg, opt:%noreg<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> lea: %R1<def> = t2LEApcrelJT <jt#2>, 2, pred:14, pred:%noreg<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>From this we see that the BaseReg = R1. R1 also happens to be the register used in the t2ADDrs calculation as well as defined by the t2LEApcrelJT operation. Because R1 is defined by t2LEApcrelJT, the restriction is met. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>However, in the next example, it fails:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>5808B BB#30: derived from LLVM BB %105<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Live Ins: %R4 %R6 %D8 %Q5 %R9 %R7 %R8 %R10 %R5 %R11<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Predecessors according to CFG: BB#29<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>5840B %R3<def> = t2LEApcrelJT <jt#1>, 1, pred:14, pred:%noreg<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>5856B %R2<def> = t2ADDrs %R3<kill>, %R7, 18, pred:14, pred:%noreg, opt:%noreg<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>5872B t2BR_JT %R2<kill>, %R7<kill>, <jt#1>, 1<o:p></o:p></span></p><p class=MsoNormal style='background:white'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Successors according to CFG: BB#90(17) BB#31(17) BB#32(17) BB#33(17) BB#34(17) BB#51(17)<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Here we see that the BaseReg = R2. But the t2LEApcrelJT instruction defines R3, not R2. But this is should be fine, because the t2ADDrs instruction takes R3 and defines R2, which is the real base address. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So my question is why is the restriction <span style='font-family:"Courier New"'>LeaMI->getOperand(0).getReg() != BaseReg</span> there? Shouldn’t the restriction be trying to ensure that the register defined by t2LEApcrelJT also be the register used by the t2ADDrs instruction? It seems this test is being overly restrictive.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Daniel<o:p></o:p></p></div></body></html>