[PATCH] D36504: [CodeGenPrepare][WIP] Convert uncond. branch to return into a return to help with shrink-wrapping

Jun Bum Lim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 10:09:58 PDT 2017


junbuml added a comment.

- Overall, I agree with the idea. I didn't see any performance differences in Xalancbmk and h264ref on AArach64 though.  I guess this will not leave a branch instruction in the empty block as it directly return.
- Should the predecessor branching to an empty return block also be empty? Your implementation doesn't seem to check if the predecessor is empty.
- Just curious about the -5% in h264ref on PPC?



================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:653
+  for (BasicBlock &BB : F)
+    MadeChange |= dupRetFedByEmptyBlocks(&BB);
+  return MadeChange;
----------------
Isn't it possible to do this in the main loop of eliminateMostlyEmptyBlocks()?


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:2625-2627
+/// Look for opportunities to duplicate a return instruction into a predecessor
+/// that does nothing but branch to the return block. Namely, duplicate a return
+/// statement in both of bb0/bb1 below:
----------------
It seems that you didn't check if the predecessor is empty? Is this what you intended? 


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:2639-2640
+  BasicBlock *SingleSucc = BB->getSingleSuccessor();
+  DEBUG(dbgs() << "Trying to duplicate the successor's return into: ");
+  DEBUG(BB->dump());
+  // Look at blocks that have a single successor
----------------
I guess you might reduce DEBUGs in this function. Right?


================
Comment at: test/CodeGen/MIR/Generic/early-ret-bb.mir:1
+# RUN: llc -run-pass codegenprepare -o - %s | FileCheck %s
+
----------------
Why do you use .mir, instead of .ll? 


Repository:
  rL LLVM

https://reviews.llvm.org/D36504





More information about the llvm-commits mailing list