[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
Sun Mar 29 21:18:43 PDT 2015


This definitely seems like a good patch. A couple of high-level thoughts:

1. You can test this directly by printing the analysis. I think we have a few tests like that.

2. You should comment what is going on here and why.

3. I feel like you need to handle more cases - != 0 at least, and maybe a few others maybe with a few other math operations?


================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:385
@@ -384,1 +384,3 @@
     case CmpInst::ICMP_EQ:
+      {
+        Instruction *LHS = dyn_cast<Instruction>(CI->getOperand(0));
----------------
If you need braces, just put them around the entire case.

================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:387
@@ +386,3 @@
+        Instruction *LHS = dyn_cast<Instruction>(CI->getOperand(0));
+        if (LHS && LHS->getOpcode() == Instruction::And)
+          return false;
----------------
I would use o two-level if with a condition expression. I find the && trick awkward.

http://reviews.llvm.org/D8165

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






More information about the llvm-commits mailing list