[PATCH] D39368: DAG: Add computeKnownBitsForFrameIndex

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 10:02:00 PST 2017


Matt Arsenault via Phabricator <reviews at reviews.llvm.org> writes:
> arsenm updated this revision to Diff 121586.
> arsenm added a comment.
>
> Add comment, move current handling into default implementation

LGTM.

>
> https://reviews.llvm.org/D39368
>
> Files:
>   include/llvm/Target/TargetLowering.h
>   lib/CodeGen/SelectionDAG/SelectionDAG.cpp
>   lib/CodeGen/SelectionDAG/TargetLowering.cpp
>
> Index: lib/CodeGen/SelectionDAG/TargetLowering.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/TargetLowering.cpp
> +++ lib/CodeGen/SelectionDAG/TargetLowering.cpp
> @@ -1288,6 +1288,19 @@
>    Known.resetAll();
>  }
>  
> +void TargetLowering::computeKnownBitsForFrameIndex(const SDValue Op,
> +                                                   KnownBits &Known,
> +                                                   const APInt &DemandedElts,
> +                                                   const SelectionDAG &DAG,
> +                                                   unsigned Depth) const {
> +  assert(isa<FrameIndexSDNode>(Op) && "expected FrameIndex");
> +
> +  if (unsigned Align = DAG.InferPtrAlignment(Op)) {
> +    // The low bits are known zero if the pointer is aligned.
> +    Known.Zero.setLowBits(Log2_32(Align));
> +  }
> +}
> +
>  /// This method can be implemented by targets that want to expose additional
>  /// information about sign bits to the DAG Combiner.
>  unsigned TargetLowering::ComputeNumSignBitsForTargetNode(SDValue Op,
> Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> @@ -2893,11 +2893,7 @@
>    }
>    case ISD::FrameIndex:
>    case ISD::TargetFrameIndex:
> -    if (unsigned Align = InferPtrAlignment(Op)) {
> -      // The low bits are known zero if the pointer is aligned.
> -      Known.Zero.setLowBits(Log2_32(Align));
> -      break;
> -    }
> +    TLI->computeKnownBitsForFrameIndex(Op, Known, DemandedElts, *this, Depth);
>      break;
>  
>    default:
> Index: include/llvm/Target/TargetLowering.h
> ===================================================================
> --- include/llvm/Target/TargetLowering.h
> +++ include/llvm/Target/TargetLowering.h
> @@ -2678,6 +2678,15 @@
>                                               const SelectionDAG &DAG,
>                                               unsigned Depth = 0) const;
>  
> +  /// Determine which of the bits of FrameIndex \p FIOp are known to be 0.
> +  /// Default implementation computes low bits based on alignment
> +  /// information. This should preserve known bits passed into it.
> +  virtual void computeKnownBitsForFrameIndex(const SDValue FIOp,
> +                                             KnownBits &Known,
> +                                             const APInt &DemandedElts,
> +                                             const SelectionDAG &DAG,
> +                                             unsigned Depth = 0) const;
> +
>    /// This method can be implemented by targets that want to expose additional
>    /// information about sign bits to the DAG Combiner. The DemandedElts
>    /// argument allows us to only collect the minimum sign bits that are shared
>



More information about the llvm-commits mailing list