<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">ARM does predicated returns in ARM and Thumb2 code. Perhaps there’s something there that might help?<div><br></div><div>-Jim</div><div><br><div><div>On Apr 10, 2013, at 10:45 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Evan, et al.,<br><br>I've come across a small issue when using the if conversion pass in PPC to generate conditional returns. Here's a small example:<br><br>** Before if conversion **<br><br>BB#0: derived from LLVM BB %entry<br> %R3<def> = LI 0<br> %CR0<def> = CMPLWI %R3, 0<br> BCC 68, %CR0, <BB#3><br> Successors according to CFG: BB#3(16) BB#1(16)<br><br>BB#1: derived from LLVM BB %while.body.lr.ph<br> Live Ins: %R3<br> Predecessors according to CFG: BB#0<br> %CR0<def> = CMPLWI %R3<kill>, 0<br> BCC 68, %CR0, <BB#3><br> Successors according to CFG: BB#3(16) BB#2(16)<br><br>BB#2: derived from LLVM BB %while.body<br> Predecessors according to CFG: BB#2 BB#1<br> B <BB#2><br> Successors according to CFG: BB#2<br><br>BB#3: derived from LLVM BB %while.end<br> Predecessors according to CFG: BB#0 BB#1<br> BLR %LR<imp-use>, %RM<imp-use><br><br>** After if conversion **<br><br>BB#0: derived from LLVM BB %entry<br> %R3<def> = LI 0<br> %CR0<def> = CMPLWI %R3, 0<br> BCC 68, %CR0, <BB#3><br> Successors according to CFG: BB#3(16) BB#1(16)<br><br>BB#1: derived from LLVM BB %while.body.lr.ph<br> Live Ins: %R3<br> Predecessors according to CFG: BB#0<br> %CR0<def> = CMPLWI %R3<kill>, 0<br> BCLR 68, %CR0, %LR<imp-use>, %RM<imp-use><br> Successors according to CFG: BB#3(16) BB#2(16)<br><br>BB#2: derived from LLVM BB %while.body<br> Predecessors according to CFG: BB#2 BB#1<br> B <BB#2><br> Successors according to CFG: BB#2<br><br>BB#3: derived from LLVM BB %while.end<br> Predecessors according to CFG: BB#0 BB#1<br> BLR %LR<imp-use>, %RM<imp-use><br><br>While the resulting code is not incorrect, the CFG is not quite right, and this pessimizes later transformations. Specifically, the issue is that BB#1 still lists BB#3 as a successor, but this is not true. Looking at IfConversion.cpp, I see this function:<br><br>/// RemoveExtraEdges - Remove true / false edges if either / both are no longer<br>/// successors.<br>void IfConverter::RemoveExtraEdges(BBInfo &BBI) {<br> MachineBasicBlock *TBB = NULL, *FBB = NULL;<br> SmallVector<MachineOperand, 4> Cond;<br> if (!TII->AnalyzeBranch(*BBI.BB, TBB, FBB, Cond))<br> BBI.BB->CorrectExtraCFGEdges(TBB, FBB, !Cond.empty());<br>}<br><br>and I think that this function is supposed to clean up the successors of BB#1 after merging. The problem is that the PPC implementation of AnalyzeBranch does not understand returns (conditional or otherwise). I'm not sure what the best way of dealing with this is. Should AnalyzeBranch be enhanced to somehow indicate conditional returns?<br><br>Alternatively, the diamond conversion routine contains this:<br><br> // RemoveExtraEdges won't work if the block has an unanalyzable branch,<br> // which can happen here if TailBB is unanalyzable and is merged, so<br> // explicitly remove BBI1 and BBI2 as successors.<br> BBI.BB->removeSuccessor(BBI1->BB);<br> BBI.BB->removeSuccessor(BBI2->BB);<br> RemoveExtraEdges(BBI);<br><br>should something similar be added prior to the calls to RemoveExtraEdges in the simple and triangle conversion routines?<br><br>Thanks in advance,<br>Hal<br><br>--<span class="Apple-converted-space"> </span><br>Hal Finkel<br>Postdoctoral Appointee<br>Leadership Computing Facility<br>Argonne National Laboratory<br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span> <a href="http://llvm.cs.uiuc.edu/">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></div></body></html>