Skip to content
  • Chris Lattner's avatar
    Speed up the mem2reg transform for allocas which are only read/written in a single · 80471529
    Chris Lattner authored
    basic block.  This is amazingly common in code generated by the C/C++ front-ends.
    This change makes it not have to insert ANY phi nodes, whereas before it would insert
    a ton of dead ones which DCE would have to clean up.
    
    Thus, this fix improves compile-time performance of these trivial allocas in two ways:
      1. It doesn't have to do the walking and book-keeping for renaming
      2. It does not insert dead phi nodes for them which would have to
         subsequently be cleaned up.
    
    On my favorite testcase from 252.eon, this special case handles 305 out of
    356 promoted allocas in the function.  It speeds up the mem2reg pass from 7.5256s
    to 1.2505s.  It inserts 677 fewer dead PHI nodes, which speeds up a subsequent
    -dce pass from 18.7524s to 2.4806s.
    
    There are still 120 trivially dead PHI nodes being inserted for variables used
    in multiple basic blocks, but they are not handled by this patch.
    
    llvm-svn: 8881
    80471529
Loading