[PATCH] D46662: [X86] condition branches folding for three-way conditional codes

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 25 17:25:41 PDT 2018


craig.topper added inline comments.


================
Comment at: lib/Target/X86/X86CondBrFolding.cpp:141
+                     SmallVectorImpl<MachineBasicBlock *> &BranchPath) {
+  TargetMBBInfo *MBBInfo = &*(MBBInfos.find(MBB)->second.get());
+  int CmpValue = MBBInfo->CmpValue;
----------------
Drop the &*


================
Comment at: lib/Target/X86/X86CondBrFolding.cpp:395
+    auto MBBInfoP = analyzeMBB(MBB);
+    if (!MBBInfoP) {
+      MBBInfos.insert(std::make_pair(&MBB, nullptr));
----------------
No need for a condition here. If you return a null std::unique_ptr it can still be moved into the map. Though since you've create an entry in the map for every basic block you might be able to use a vector indexed by MBB_>getNumber. You can get the total number of indices to intially size the vetor from MF->getNumBlockIDs(). Then you can use operator[] on the vector instead of find. This should work as long as no basic blocks are created by this pass.


================
Comment at: lib/Target/X86/X86CondBrFolding.cpp:404
+    auto It = MBBInfos.find(&MBB);
+    TargetMBBInfo *MBBInfo = &(*It->second.get());
+    if (!MBBInfo || !MBBInfo->CmpBrOnly)
----------------
No need for the * and & here.


================
Comment at: lib/Target/X86/X86CondBrFolding.cpp:499
+  if (MBB.succ_size() != 2)
+    return std::unique_ptr<TargetMBBInfo>{};
+
----------------
Can you just return nullptr instead of default constructed std::unique_ptr?


https://reviews.llvm.org/D46662





More information about the llvm-commits mailing list