Hi Pedro,<div><br></div><div>Looking much better. How about some comments now?</div><div><br></div><div>-eric</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 30, 2012 at 2:47 PM, Pedro Artigas <span dir="ltr"><<a href="mailto:partigas@apple.com" target="_blank">partigas@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: partigas<br>
Date: Fri Nov 30 16:47:15 2012<br>
New Revision: 169049<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=169049&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=169049&view=rev</a><br>
Log:<br>
<br>
reversed the logic of the log2 detection routine to reduce the number of nested ifs<br>
<br>
<br>
Modified:<br>
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=169049&r1=169048&r2=169049&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=169049&r1=169048&r2=169049&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Fri Nov 30 16:47:15 2012<br>
@@ -261,31 +261,35 @@<br>
//<br>
<br>
static void detectLog2OfHalf(Value *&Op, Value *&Y, IntrinsicInst *&Log2) {<br>
- if (Op->hasOneUse()) {<br>
- if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op)) {<br>
- if (II->getIntrinsicID() == Intrinsic::log2 &&<br>
- II->hasUnsafeAlgebra()) {<br>
- Log2 = II;<br>
- Value *OpLog2Of = II->getArgOperand(0);<br>
- if (OpLog2Of->hasOneUse()) {<br>
- if (Instruction *I = dyn_cast<Instruction>(OpLog2Of)) {<br>
- if (I->getOpcode() == Instruction::FMul &&<br>
- I->hasUnsafeAlgebra()) {<br>
- ConstantFP *CFP = dyn_cast<ConstantFP>(I->getOperand(0));<br>
- if (CFP && CFP->isExactlyValue(0.5)) {<br>
- Y = I->getOperand(1);<br>
- } else {<br>
- CFP = dyn_cast<ConstantFP>(I->getOperand(1));<br>
- if (CFP && CFP->isExactlyValue(0.5)) {<br>
- Y = I->getOperand(0);<br>
- }<br>
- }<br>
- }<br>
- }<br>
- }<br>
- }<br>
- }<br>
- }<br>
+<br>
+ if (!Op->hasOneUse())<br>
+ return;<br>
+<br>
+ IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op);<br>
+ if (!II)<br>
+ return;<br>
+ if (II->getIntrinsicID() != Intrinsic::log2 || !II->hasUnsafeAlgebra())<br>
+ return;<br>
+ Log2 = II;<br>
+<br>
+ Value *OpLog2Of = II->getArgOperand(0);<br>
+ if (!OpLog2Of->hasOneUse())<br>
+ return;<br>
+<br>
+ Instruction *I = dyn_cast<Instruction>(OpLog2Of);<br>
+ if (!I)<br>
+ return;<br>
+ if (I->getOpcode() != Instruction::FMul || !I->hasUnsafeAlgebra())<br>
+ return;<br>
+<br>
+ ConstantFP *CFP = dyn_cast<ConstantFP>(I->getOperand(0));<br>
+ if (CFP && CFP->isExactlyValue(0.5)) {<br>
+ Y = I->getOperand(1);<br>
+ return;<br>
+ }<br>
+ CFP = dyn_cast<ConstantFP>(I->getOperand(1));<br>
+ if (CFP && CFP->isExactlyValue(0.5))<br>
+ Y = I->getOperand(0);<br>
}<br>
<br>
Instruction *InstCombiner::visitFMul(BinaryOperator &I) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>