[llvm-commits] [llvm] r108109 - /llvm/trunk/lib/CodeGen/MachineLICM.cpp

Evan Cheng evan.cheng at apple.com
Mon Jul 12 01:04:38 PDT 2010



On Jul 11, 2010, at 5:00 PM, Chris Lattner <sabre at nondot.org> wrote:

> Author: lattner
> Date: Sun Jul 11 19:00:35 2010
> New Revision: 108109
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=108109&view=rev
> Log:
> change machinelicm to use MachineInstr::isSafeToMove.  No
> intended functionality change.
> 
> The avoidance of hoistiing implicitdef seems wrong though.
> 
> Modified:
>    llvm/trunk/lib/CodeGen/MachineLICM.cpp
> 
> Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=108109&r1=108108&r2=108109&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Sun Jul 11 19:00:35 2010
> @@ -127,8 +127,8 @@
>     void AddToLiveIns(unsigned Reg);
> 
>     /// IsLICMCandidate - Returns true if the instruction may be a suitable
> -    /// candidate for LICM. e.g. If the instruction is a call, then it's obviously
> -    /// not safe to hoist it.
> +    /// candidate for LICM. e.g. If the instruction is a call, then it's
> +    /// obviously not safe to hoist it.
>     bool IsLICMCandidate(MachineInstr &I);
> 
>     /// IsLoopInvariantInst - Returns true if the instruction is loop
> @@ -497,26 +497,16 @@
> /// candidate for LICM. e.g. If the instruction is a call, then it's obviously
> /// not safe to hoist it.
> bool MachineLICM::IsLICMCandidate(MachineInstr &I) {
> +  // It is not profitable to hoist implicitdefs.  FIXME: Why not?  what if they
> +  // are an argument to some other otherwise-hoistable instruction?

I think this can to be handled specifically during check for loop invariant. If an operand is non-invariant implicitdef, this pass can create an invariant implicitdef operand to allow the instruction to be hoisted. 

Evan
 
>   if (I.isImplicitDef())
>     return false;
> -
> -  const TargetInstrDesc &TID = I.getDesc();
> 
> -  // Ignore stuff that we obviously can't hoist.
> -  if (TID.mayStore() || TID.isCall() || TID.isTerminator() ||
> -      TID.hasUnmodeledSideEffects())
> +  // Check if it's safe to move the instruction.
> +  bool DontMoveAcrossStore = true;
> +  if (!I.isSafeToMove(TII, AA, DontMoveAcrossStore))
>     return false;
> -
> -  if (TID.mayLoad()) {
> -    // Okay, this instruction does a load. As a refinement, we allow the target
> -    // to decide whether the loaded value is actually a constant. If so, we can
> -    // actually use it as a load.
> -    if (!I.isInvariantLoad(AA))
> -      // FIXME: we should be able to hoist loads with no other side effects if
> -      // there are no other instructions which can change memory in this loop.
> -      // This is a trivial form of alias analysis.
> -      return false;
> -  }
> +  
>   return true;
> }
> 
> 
> 
> _______________________________________________
> 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