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

Evan Cheng evan.cheng at apple.com
Wed Oct 19 16:35:15 PDT 2011


How about loads from constant pool and other such loads? See MachineInstr::isInvariantLoad()?

Evan

On Oct 17, 2011, at 10:35 AM, Devang Patel wrote:

> Author: dpatel
> Date: Mon Oct 17 12:35:01 2011
> New Revision: 142202
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=142202&view=rev
> Log:
> It is safe to speculate load from GOT. This fixes performance regression caused by r141689.
> 
> Radar 10281206.
> 
> 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=142202&r1=142201&r2=142202&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Mon Oct 17 12:35:01 2011
> @@ -762,6 +762,21 @@
>   }
> }
> 
> +/// isLoadFromGOT - Return true if this machine instruction loads from
> +/// global offset table.
> +static bool isLoadFromGOT(MachineInstr &MI) {
> +  assert (MI.getDesc().mayLoad() && "Expected MI that loads!");
> +  for (MachineInstr::mmo_iterator I = MI.memoperands_begin(),
> +	 E = MI.memoperands_end(); I != E; ++I) {
> +    if (const Value *V = (*I)->getValue()) {
> +      if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V))
> +        if (PSV == PSV->getGOT())
> +	  return true;
> +    }
> +  }
> +  return false;
> +}
> +
> /// 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.
> @@ -775,7 +790,8 @@
>   // it dominates all exiting blocks. If it doesn't, then there is a path out of
>   // the loop which does not execute this load, so we can't hoist it.
>   // Stores and side effects are already checked by isSafeToMove.
> -  if (I.getDesc().mayLoad() && !IsGuaranteedToExecute(I.getParent()))
> +  if (I.getDesc().mayLoad() && !isLoadFromGOT(I) && 
> +      !IsGuaranteedToExecute(I.getParent()))
>     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