[PATCH] D14596: [SROA] Choose more profitable type in findCommonType

David Li via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 23 15:21:27 PST 2016


davidxl added a comment.

Can you also add a test case with multiple levels of phis?


================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1795
@@ +1794,3 @@
+///     B  ->  A    cast
+Instruction *InstCombiner::optimizeBitCastFromPhi(CastInst &CI, PHINode *PN) {
+  Value *Src = CI.getOperand(0);
----------------
Add more documentation of the method:
Replace \p CI instruction with a new PHI ...

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1797
@@ +1796,3 @@
+  Value *Src = CI.getOperand(0);
+  Type *SrcTy = Src->getType();
+  Type *DestTy = CI.getType();
----------------
add comment -- type B

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1798
@@ +1797,3 @@
+  Type *SrcTy = Src->getType();
+  Type *DestTy = CI.getType();
+
----------------
comment type A

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1804
@@ +1803,3 @@
+  PNodes.insert(PN);
+  for (unsigned i=0; i < PNodes.size(); ++i) {
+    PHINode *OldPN = PNodes[i];
----------------
Use the more common worklist pattern:

while (!Worklist.empty()) {
  PHINode *Item = Worklist.pop();
  if (!ResultSet.insert(Item)) // already processed
      continue;
  // process Item
   ...
    Worklist.insert(IncValue);
 }
    

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1842
@@ +1841,3 @@
+  ConstantFolder CFolder;
+  for (unsigned i=0; i < PNodes.size(); ++i) {
+    PHINode *OldPN = PNodes[i];
----------------
use range based iteration : for (auto OldPN : PNodes) { }

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1845
@@ +1844,3 @@
+    PHINode *NewPN = NewPNodes[OldPN];
+    for (unsigned j=0, e=OldPN->getNumOperands(); j < e; ++j) {
+      Value *V = OldPN->getOperand(j);
----------------
clang formatting with space:
 for (unsigned J = 0, E = OldPN-> ...) {


http://reviews.llvm.org/D14596





More information about the llvm-commits mailing list