[llvm-commits] [llvm] r136989 - in /llvm/trunk/lib/CodeGen: RegAllocGreedy.cpp SplitKit.cpp SplitKit.h

Nick Lewycky nicholas at mxc.ca
Sat Aug 6 14:01:02 PDT 2011


Jakob Stoklund Olesen wrote:
> Author: stoklund
> Date: Fri Aug  5 17:20:45 2011
> New Revision: 136989
>
> URL: http://llvm.org/viewvc/llvm-project?rev=136989&view=rev
> Log:
> Split around single instructions to enable register class inflation.
>
> Normally, we don't create a live range for a single instruction in a
> basic block, the spiller does that anyway. However, when splitting a
> live range that belongs to a proper register sub-class, inserting these
> extra COPY instructions completely remove the constraints from the
> remainder interval, and it may be allocated from the larger super-class.
>
> The spiller will mop up these small live ranges if we end up spilling
> anyway. It calls them snippets.
>
> Modified:
>      llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
>      llvm/trunk/lib/CodeGen/SplitKit.cpp
>      llvm/trunk/lib/CodeGen/SplitKit.h
>
> Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=136989&r1=136988&r2=136989&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
> +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Fri Aug  5 17:20:45 2011
> @@ -942,6 +942,12 @@
>     DEBUG(dbgs()<<  "splitAroundRegion with "<<  NumGlobalIntvs<<  " globals.\n");
>     assert(NumGlobalIntvs&&  "No global intervals configured");
>
> +  // Isolate even single instructions when dealing with a proper sub-class.
> +  // That giarantees register class inflation for the stack interval because it

typo, "giarantees"

Nick

> +  // is all copies.
> +  unsigned Reg = SA->getParent().reg;
> +  bool SingleInstrs = RegClassInfo.isProperSubClass(MRI->getRegClass(Reg));
> +
>     // First handle all the blocks with uses.
>     ArrayRef<SplitAnalysis::BlockInfo>  UseBlocks = SA->getUseBlocks();
>     for (unsigned i = 0; i != UseBlocks.size(); ++i) {
> @@ -971,7 +977,7 @@
>       // Create separate intervals for isolated blocks with multiple uses.
>       if (!IntvIn&&  !IntvOut) {
>         DEBUG(dbgs()<<  "BB#"<<  BI.MBB->getNumber()<<  " isolated.\n");
> -      if (!BI.isOneInstr())
> +      if (SA->shouldSplitSingleBlock(BI, SingleInstrs))
>           SE->splitSingleBlock(BI);
>         continue;
>       }
>
> Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=136989&r1=136988&r2=136989&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Fri Aug  5 17:20:45 2011
> @@ -1087,6 +1087,24 @@
>   //                            Single Block Splitting
>   //===----------------------------------------------------------------------===//
>
> +bool SplitAnalysis::shouldSplitSingleBlock(const BlockInfo&BI,
> +                                           bool SingleInstrs) const {
> +  // Always split for multiple instructions.
> +  if (!BI.isOneInstr())
> +    return true;
> +  // Don't split for single instructions unless explicitly requested.
> +  if (!SingleInstrs)
> +    return false;
> +  // Splitting a live-through range always makes progress.
> +  if (BI.LiveIn&&  BI.LiveOut)
> +    return true;
> +  // No point in isolating a copy. It has no register class constraints.
> +  if (LIS.getInstructionFromIndex(BI.FirstInstr)->isCopyLike())
> +    return false;
> +  // Finally, don't isolate an end point that was created by earlier splits.
> +  return isOriginalEndpoint(BI.FirstInstr);
> +}
> +
>   /// getMultiUseBlocks - if CurLI has more than one use in a basic block, it
>   /// may be an advantage to split CurLI for the duration of the block.
>   bool SplitAnalysis::getMultiUseBlocks(BlockPtrSet&Blocks) {
>
> Modified: llvm/trunk/lib/CodeGen/SplitKit.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=136989&r1=136988&r2=136989&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SplitKit.h (original)
> +++ llvm/trunk/lib/CodeGen/SplitKit.h Fri Aug  5 17:20:45 2011
> @@ -185,6 +185,16 @@
>
>     typedef SmallPtrSet<const MachineBasicBlock*, 16>  BlockPtrSet;
>
> +  /// shouldSplitSingleBlock - Returns true if it would help to create a local
> +  /// live range for the instructions in BI. There is normally no benefit to
> +  /// creating a live range for a single instruction, but it does enable
> +  /// register class inflation if the instruction has a restricted register
> +  /// class.
> +  ///
> +  /// @param BI           The block to be isolated.
> +  /// @param SingleInstrs True when single instructions should be isolated.
> +  bool shouldSplitSingleBlock(const BlockInfo&BI, bool SingleInstrs) const;
> +
>     /// getMultiUseBlocks - Add basic blocks to Blocks that may benefit from
>     /// having CurLI split to a new live interval. Return true if Blocks can be
>     /// passed to SplitEditor::splitSingleBlocks.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list