Use the new script to sort the includes of every file under lib.
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombineMulDivRem.cpp
index b0b9bac8f755722fcd4c9273c6aacb9cc8975f88..5cd611c4200adb819f93b491a18fd4fe28a47d2a 100644 (file)
@@ -13,8 +13,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "InstCombine.h"
-#include "llvm/IntrinsicInst.h"
 #include "llvm/Analysis/InstructionSimplify.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Support/PatternMatch.h"
 using namespace llvm;
 using namespace PatternMatch;
@@ -261,31 +261,35 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
 //
 
 static void detectLog2OfHalf(Value *&Op, Value *&Y, IntrinsicInst *&Log2) {
-   if (Op->hasOneUse()) {
-    if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op)) {
-      if (II->getIntrinsicID() == Intrinsic::log2 &&
-          II->hasUnsafeAlgebra()) {
-        Log2 = II;
-        Value *OpLog2Of = II->getArgOperand(0);
-        if (OpLog2Of->hasOneUse()) {
-          if (Instruction *I = dyn_cast<Instruction>(OpLog2Of)) {
-            if (I->getOpcode() == Instruction::FMul &&
-                I->hasUnsafeAlgebra()) {
-              ConstantFP *CFP = dyn_cast<ConstantFP>(I->getOperand(0));
-              if (CFP && CFP->isExactlyValue(0.5)) {
-                Y = I->getOperand(1);
-              } else {
-                CFP = dyn_cast<ConstantFP>(I->getOperand(1));
-                if (CFP && CFP->isExactlyValue(0.5)) {
-                  Y = I->getOperand(0);
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
+
+   if (!Op->hasOneUse())
+     return;
+
+   IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op);
+   if (!II)
+     return;
+   if (II->getIntrinsicID() != Intrinsic::log2 || !II->hasUnsafeAlgebra())
+     return;
+   Log2 = II;
+
+   Value *OpLog2Of = II->getArgOperand(0);
+   if (!OpLog2Of->hasOneUse())
+     return;
+
+   Instruction *I = dyn_cast<Instruction>(OpLog2Of);
+   if (!I)
+     return;
+   if (I->getOpcode() != Instruction::FMul || !I->hasUnsafeAlgebra())
+     return;
+              
+   ConstantFP *CFP = dyn_cast<ConstantFP>(I->getOperand(0));
+   if (CFP && CFP->isExactlyValue(0.5)) {
+     Y = I->getOperand(1);
+     return;
+   }
+   CFP = dyn_cast<ConstantFP>(I->getOperand(1));
+   if (CFP && CFP->isExactlyValue(0.5))
+     Y = I->getOperand(0);
 } 
 
 Instruction *InstCombiner::visitFMul(BinaryOperator &I) {