<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=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@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:12.0pt;
font-family:"Times New Roman",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-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.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"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I should have a fix soon.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">This case is also broken independent of the recent patch<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">unsigned foo(int input) {
<span style="color:red">// signed type<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> if (input < 0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> input = -input; <span style="color:red">
// absolute value<o:p></o:p></span></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""> unsigned num = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> do {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> ++num;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> input >>= 1;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> } while (input != 0);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> return num;<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""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">int main() {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">__builtin_printf("%u\n", foo(0));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Eric Christopher [mailto:echristo@gmail.com]
<br>
<b>Sent:</b> Wednesday, July 11, 2018 2:54 PM<br>
<b>To:</b> Wei Mi <wmi@google.com><br>
<b>Cc:</b> Topper, Craig <craig.topper@intel.com>; llvm-commits <llvm-commits@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm] r336509 - [LoopIdiomRecognize] Support for converting loops that use LSHR to CTLZ.<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Craig,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Since we have a testcase here, could we get this reverted until we can get a fix (unless you'll have one shortly of course :).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-eric<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Jul 11, 2018 at 1:43 PM Wei Mi via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">Hi, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">We run into a SEGV in a testcase. Here is a reproducible. Please take a look.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">----------- 1.cc -------------<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">unsigned foo(unsigned input) {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> unsigned num = 0;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> do {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> ++num;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> input >>= 1;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> } while (input != 0);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> return num;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">int main() {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> __builtin_printf("%u\n", foo(0));<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal">---------------------------------<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="background:white">~/workarea/llvm-</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black;background:white">r336508</span><span style="background:white">/rbuild/bin/clang -O2 1.cc -o good.out; ./good.out</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="background:white">1</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">~/workarea/llvm-<span style="font-family:"Arial",sans-serif;color:black;background:white">r336509</span>/rbuild/bin/clang -O2 1.cc -o bad.out; ./bad.out<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">0<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Wei.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Sat, Jul 7, 2018 at 6:45 PM, Craig Topper via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: ctopper<br>
Date: Sat Jul 7 18:45:47 2018<br>
New Revision: 336509<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=336509&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=336509&view=rev</a><br>
Log:<br>
[LoopIdiomRecognize] Support for converting loops that use LSHR to CTLZ.<br>
<br>
In the 'detectCTLZIdiom' function support for loops that use LSHR instruction instead of ASHR has been added.<br>
<br>
This supports creating ctlz from the following code.<br>
<br>
int lzcnt(int x) {<br>
int count = 0;<br>
while (x > 0) {<br>
count++;<br>
x = x >> 1;<br>
}<br>
return count;<br>
}<br>
<br>
Patch by Olga Moldovanova<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D48354" target="_blank">
https://reviews.llvm.org/D48354</a><br>
<br>
Modified:<br>
llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp<br>
llvm/trunk/test/Transforms/LoopIdiom/X86/ctlz.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=336509&r1=336508&r2=336509&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=336509&r1=336508&r2=336509&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Sat Jul 7 18:45:47 2018<br>
@@ -188,8 +188,9 @@ private:<br>
PHINode *CntPhi, Value *Var);<br>
bool recognizeAndInsertCTLZ();<br>
void transformLoopToCountable(BasicBlock *PreCondBB, Instruction *CntInst,<br>
- PHINode *CntPhi, Value *Var, const DebugLoc &DL,<br>
- bool ZeroCheck, bool IsCntPhiUsedOutsideLoop);<br>
+ PHINode *CntPhi, Value *Var, Instruction *DefX,<br>
+ const DebugLoc &DL, bool ZeroCheck,<br>
+ bool IsCntPhiUsedOutsideLoop);<br>
<br>
/// @}<br>
};<br>
@@ -1316,8 +1317,8 @@ static bool detectCTLZIdiom(Loop *CurLoo<br>
return false;<br>
<br>
// step 2: detect instructions corresponding to "x.next = x >> 1"<br>
- // TODO: Support loops that use LShr.<br>
- if (!DefX || DefX->getOpcode() != Instruction::AShr)<br>
+ if (!DefX || (DefX->getOpcode() != Instruction::AShr &&<br>
+ DefX->getOpcode() != Instruction::LShr))<br>
return false;<br>
ConstantInt *Shft = dyn_cast<ConstantInt>(DefX->getOperand(1));<br>
if (!Shft || !Shft->isOne())<br>
@@ -1401,8 +1402,7 @@ bool LoopIdiomRecognize::recognizeAndIns<br>
<br>
// Make sure the initial value can't be negative otherwise the ashr in the<br>
// loop might never reach zero which would make the loop infinite.<br>
- // TODO: Support loops that use lshr and wouldn't need this check.<br>
- if (!isKnownNonNegative(InitX, *DL))<br>
+ if (DefX->getOpcode() == Instruction::AShr && !isKnownNonNegative(InitX, *DL))<br>
return false;<br>
<br>
// If we check X != 0 before entering the loop we don't need a zero<br>
@@ -1433,8 +1433,9 @@ bool LoopIdiomRecognize::recognizeAndIns<br>
TargetTransformInfo::TCC_Basic)<br>
return false;<br>
<br>
- transformLoopToCountable(PH, CntInst, CntPhi, InitX, DefX->getDebugLoc(),<br>
- ZeroCheck, IsCntPhiUsedOutsideLoop);<br>
+ transformLoopToCountable(PH, CntInst, CntPhi, InitX, DefX,<br>
+ DefX->getDebugLoc(), ZeroCheck,<br>
+ IsCntPhiUsedOutsideLoop);<br>
return true;<br>
}<br>
<br>
@@ -1547,7 +1548,8 @@ static CallInst *createCTLZIntrinsic(IRB<br>
/// If CntInst and DefX are not used in LOOP_BODY they will be removed.<br>
void LoopIdiomRecognize::transformLoopToCountable(<br>
BasicBlock *Preheader, Instruction *CntInst, PHINode *CntPhi, Value *InitX,<br>
- const DebugLoc &DL, bool ZeroCheck, bool IsCntPhiUsedOutsideLoop) {<br>
+ Instruction *DefX, const DebugLoc &DL, bool ZeroCheck,<br>
+ bool IsCntPhiUsedOutsideLoop) {<br>
BranchInst *PreheaderBr = cast<BranchInst>(Preheader->getTerminator());<br>
<br>
// Step 1: Insert the CTLZ instruction at the end of the preheader block<br>
@@ -1558,10 +1560,16 @@ void LoopIdiomRecognize::transformLoopTo<br>
Builder.SetCurrentDebugLocation(DL);<br>
Value *CTLZ, *Count, *CountPrev, *NewCount, *InitXNext;<br>
<br>
- if (IsCntPhiUsedOutsideLoop)<br>
- InitXNext = Builder.CreateAShr(InitX,<br>
- ConstantInt::get(InitX->getType(), 1));<br>
- else<br>
+ if (IsCntPhiUsedOutsideLoop) {<br>
+ if (DefX->getOpcode() == Instruction::AShr)<br>
+ InitXNext =<br>
+ Builder.CreateAShr(InitX, ConstantInt::get(InitX->getType(), 1));<br>
+ else if (DefX->getOpcode() == Instruction::LShr)<br>
+ InitXNext =<br>
+ Builder.CreateLShr(InitX, ConstantInt::get(InitX->getType(), 1));<br>
+ else<br>
+ llvm_unreachable("Unexpected opcode!"); <br>
+ } else<br>
InitXNext = InitX;<br>
CTLZ = createCTLZIntrinsic(Builder, InitXNext, DL, ZeroCheck);<br>
Count = Builder.CreateSub(<br>
<br>
Modified: llvm/trunk/test/Transforms/LoopIdiom/X86/ctlz.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopIdiom/X86/ctlz.ll?rev=336509&r1=336508&r2=336509&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopIdiom/X86/ctlz.ll?rev=336509&r1=336508&r2=336509&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/LoopIdiom/X86/ctlz.ll (original)<br>
+++ llvm/trunk/test/Transforms/LoopIdiom/X86/ctlz.ll Sat Jul 7 18:45:47 2018<br>
@@ -119,6 +119,52 @@ while.end:<br>
; Here it will replace the loop -<br>
; assume builtin is always profitable.<br>
;<br>
+; int ctlz_zero_check_lshr(int n)<br>
+; {<br>
+; int i = 0;<br>
+; while(n) {<br>
+; n >>= 1;<br>
+; i++;<br>
+; }<br>
+; return i;<br>
+; }<br>
+;<br>
+; ALL: entry<br>
+; ALL: %0 = call i32 @llvm.ctlz.i32(i32 %n, i1 true)<br>
+; ALL-NEXT: %1 = sub i32 32, %0<br>
+; ALL: %inc.lcssa = phi i32 [ %1, %while.body ]<br>
+; ALL: %i.0.lcssa = phi i32 [ 0, %entry ], [ %inc.lcssa, %while.end.loopexit ]<br>
+; ALL: ret i32 %i.0.lcssa<br>
+<br>
+; Function Attrs: norecurse nounwind readnone uwtable<br>
+define i32 @ctlz_zero_check_lshr(i32 %n) {<br>
+entry:<br>
+ %tobool4 = icmp eq i32 %n, 0<br>
+ br i1 %tobool4, label %while.end, label %while.body.preheader<br>
+<br>
+while.body.preheader: ; preds = %entry<br>
+ br label %while.body<br>
+<br>
+while.body: ; preds = %while.body.preheader, %while.body<br>
+ %i.06 = phi i32 [ %inc, %while.body ], [ 0, %while.body.preheader ]<br>
+ %n.addr.05 = phi i32 [ %shr, %while.body ], [ %n, %while.body.preheader ]<br>
+ %shr = lshr i32 %n.addr.05, 1<br>
+ %inc = add nsw i32 %i.06, 1<br>
+ %tobool = icmp eq i32 %shr, 0<br>
+ br i1 %tobool, label %while.end.loopexit, label %while.body<br>
+<br>
+while.end.loopexit: ; preds = %while.body<br>
+ br label %while.end<br>
+<br>
+while.end: ; preds = %while.end.loopexit, %entry<br>
+ %i.0.lcssa = phi i32 [ 0, %entry ], [ %inc, %while.end.loopexit ]<br>
+ ret i32 %i.0.lcssa<br>
+}<br>
+<br>
+; Recognize CTLZ builtin pattern.<br>
+; Here it will replace the loop -<br>
+; assume builtin is always profitable.<br>
+;<br>
; int ctlz(int n)<br>
; {<br>
; n = n >= 0 ? n : -n;<br>
@@ -161,6 +207,44 @@ while.end:<br>
; Here it will replace the loop -<br>
; assume builtin is always profitable.<br>
;<br>
+; int ctlz_lshr(int n)<br>
+; {<br>
+; int i = 0;<br>
+; while(n >>= 1) {<br>
+; i++;<br>
+; }<br>
+; return i;<br>
+; }<br>
+;<br>
+; ALL: entry<br>
+; ALL: %0 = lshr i32 %n, 1<br>
+; ALL-NEXT: %1 = call i32 @llvm.ctlz.i32(i32 %0, i1 false)<br>
+; ALL-NEXT: %2 = sub i32 32, %1<br>
+; ALL-NEXT: %3 = add i32 %2, 1<br>
+; ALL: %i.0.lcssa = phi i32 [ %2, %while.cond ]<br>
+; ALL: ret i32 %i.0.lcssa<br>
+<br>
+; Function Attrs: norecurse nounwind readnone uwtable<br>
+define i32 @ctlz_lshr(i32 %n) {<br>
+entry:<br>
+ br label %while.cond<br>
+<br>
+while.cond: ; preds = %while.cond, %entry<br>
+ %n.addr.0 = phi i32 [ %n, %entry ], [ %shr, %while.cond ]<br>
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %while.cond ]<br>
+ %shr = lshr i32 %n.addr.0, 1<br>
+ %tobool = icmp eq i32 %shr, 0<br>
+ %inc = add nsw i32 %i.0, 1<br>
+ br i1 %tobool, label %while.end, label %while.cond<br>
+<br>
+while.end: ; preds = %while.cond<br>
+ ret i32 %i.0<br>
+}<br>
+<br>
+; Recognize CTLZ builtin pattern.<br>
+; Here it will replace the loop -<br>
+; assume builtin is always profitable.<br>
+;<br>
; int ctlz_add(int n, int i0)<br>
; {<br>
; n = n >= 0 ? n : -n;<br>
@@ -204,6 +288,45 @@ while.end:<br>
; Here it will replace the loop -<br>
; assume builtin is always profitable.<br>
;<br>
+; int ctlz_add_lshr(int n, int i0)<br>
+; {<br>
+; int i = i0;<br>
+; while(n >>= 1) {<br>
+; i++;<br>
+; }<br>
+; return i;<br>
+; }<br>
+;<br>
+; ALL: entry<br>
+; ALL: %0 = lshr i32 %n, 1<br>
+; ALL-NEXT: %1 = call i32 @llvm.ctlz.i32(i32 %0, i1 false)<br>
+; ALL-NEXT: %2 = sub i32 32, %1<br>
+; ALL-NEXT: %3 = add i32 %2, 1<br>
+; ALL-NEXT: %4 = add i32 %2, %i0<br>
+; ALL: %i.0.lcssa = phi i32 [ %4, %while.cond ]<br>
+; ALL: ret i32 %i.0.lcssa<br>
+;<br>
+; Function Attrs: norecurse nounwind readnone uwtable<br>
+define i32 @ctlz_add_lshr(i32 %n, i32 %i0) {<br>
+entry:<br>
+ br label %while.cond<br>
+<br>
+while.cond: ; preds = %while.cond, %entry<br>
+ %n.addr.0 = phi i32 [ %n, %entry ], [ %shr, %while.cond ]<br>
+ %i.0 = phi i32 [ %i0, %entry ], [ %inc, %while.cond ]<br>
+ %shr = lshr i32 %n.addr.0, 1<br>
+ %tobool = icmp eq i32 %shr, 0<br>
+ %inc = add nsw i32 %i.0, 1<br>
+ br i1 %tobool, label %while.end, label %while.cond<br>
+<br>
+while.end: ; preds = %while.cond<br>
+ ret i32 %i.0<br>
+}<br>
+<br>
+; Recognize CTLZ builtin pattern.<br>
+; Here it will replace the loop -<br>
+; assume builtin is always profitable.<br>
+;<br>
; int ctlz_sext(short in)<br>
; {<br>
; int n = in;<br>
@@ -240,6 +363,45 @@ while.cond:<br>
%tobool = icmp eq i32 %shr, 0<br>
%inc = add nsw i32 %i.0, 1<br>
br i1 %tobool, label %while.end, label %while.cond<br>
+<br>
+while.end: ; preds = %while.cond<br>
+ ret i32 %i.0<br>
+}<br>
+<br>
+; Recognize CTLZ builtin pattern.<br>
+; Here it will replace the loop -<br>
+; assume builtin is always profitable.<br>
+;<br>
+; int ctlz_sext_lshr(short in)<br>
+; {<br>
+; int i = 0;<br>
+; while(in >>= 1) {<br>
+; i++;<br>
+; }<br>
+; return i;<br>
+; }<br>
+;<br>
+; ALL: entry<br>
+; ALL: %0 = lshr i32 %n, 1<br>
+; ALL-NEXT: %1 = call i32 @llvm.ctlz.i32(i32 %0, i1 false)<br>
+; ALL-NEXT: %2 = sub i32 32, %1<br>
+; ALL-NEXT: %3 = add i32 %2, 1<br>
+; ALL: %i.0.lcssa = phi i32 [ %2, %while.cond ]<br>
+; ALL: ret i32 %i.0.lcssa<br>
+<br>
+; Function Attrs: norecurse nounwind readnone uwtable<br>
+define i32 @ctlz_sext_lshr(i16 %in) {<br>
+entry:<br>
+ %n = sext i16 %in to i32<br>
+ br label %while.cond<br>
+<br>
+while.cond: ; preds = %while.cond, %entry<br>
+ %n.addr.0 = phi i32 [ %n, %entry ], [ %shr, %while.cond ]<br>
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %while.cond ]<br>
+ %shr = lshr i32 %n.addr.0, 1<br>
+ %tobool = icmp eq i32 %shr, 0<br>
+ %inc = add nsw i32 %i.0, 1<br>
+ br i1 %tobool, label %while.end, label %while.cond<br>
<br>
while.end: ; preds = %while.cond<br>
ret i32 %i.0<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>