[PATCH] Infer known bits from dominating conditions

Sanjoy Das sanjoy at playingwithpointers.com
Mon Mar 9 18:02:44 PDT 2015


With the inline comments addressed, I think this is okay to check in, but I'll defer to someone more familiar with the area for an LGTM.

Optional: ou might want to add some negative tests too -- where optimizing based on a dominating condition would be a miscompile.


================
Comment at: lib/Analysis/ValueTracking.cpp:638
@@ +637,3 @@
+    BasicBlock *BB0 = BI->getSuccessor(0);
+    if (!Q.DT->dominates(BasicBlockEdge(BI->getParent(), BB0),
+                         Q.CxtI->getParent()))
----------------
`DominatorTree::dominates` asserts `BBE.isSingleEdge()`, so you should check that before calling `dominates`.

================
Comment at: lib/Analysis/ValueTracking.cpp:1051
@@ +1050,3 @@
+    // Or a dominating condition for that matter
+    if(EnableDomConditions && Depth <= DomConditionsMaxDepth) {
+      computeKnownBitsFromDominatingCondition(V, KnownZero, KnownOne,
----------------
Whitespace is a little off (elsewhere too), please run `clang-format` before checkin.

================
Comment at: test/Transforms/InstCombine/dom-conditions.ll:63
@@ +62,3 @@
+  %add = add i64 %A, 1
+  ret i64 %add
+untaken:
----------------
This is an interesting example -- we should be able to fold the addition completely.

(Not commenting on this change) Can `instcombine` be taught to do something if `(KnownZero | KnowOne).isAllOnesValue()` (i.e. we have complete information about a value)?

http://reviews.llvm.org/D7708

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






More information about the llvm-commits mailing list