[PATCH] Don't pretend to have probability information if the result of a bitwise and is compared against 0

Chandler Carruth chandlerc at gmail.com
Tue Apr 14 07:47:00 PDT 2015


This looks fine.

I feel like it should also be handling explicit 'i1' values as well, but that can be a separate patch.


================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:384-391
@@ +383,10 @@
+  // we don't have information about probabilities.
+  if (Instruction *LHS = dyn_cast<Instruction>(CI->getOperand(0))) {
+    if (LHS->getOpcode() == Instruction::And) {
+      if (ConstantInt *AndRHS = dyn_cast<ConstantInt>(LHS->getOperand(1))) {
+        if (AndRHS->getUniqueInteger().isPowerOf2())
+          return false;
+      }
+    }
+  }
+
----------------
I don't think these braces are useful, I'd omit all of them.

http://reviews.llvm.org/D8165

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list