[llvm-commits] [llvm] r56270 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp

Evan Cheng evan.cheng at apple.com
Tue Sep 16 21:13:22 PDT 2008


Nice art work! :-)

On Sep 16, 2008, at 6:39 PM, Dan Gohman wrote:

>
> -        // Must be a chain reading node where it is possible to  
> reach its own
> -        // chain operand through a path started from another operand.
> -        assert(Use->getOpcode() == ISD::STORE ||
> -               Use->getOpcode() == X86ISD::CMP ||
> -               Use->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
> -               Use->getOpcode() == ISD::INTRINSIC_VOID);
> -        continue;
> -      }
>
> +      assert(N != Root);

Why remove the assertion?

Evan

>
>       found = true;
>       break;
>     }
>
>     // Traverse up the operand chain.
> -    findNonImmUse(N, Def, ImmedUse, Root, Skip, found, Visited);
> +    findNonImmUse(N, Def, ImmedUse, Root, found, Visited);
>   }
> }
>
> @@ -309,11 +299,10 @@
> /// have one non-chain use, we only need to watch out for load/op/ 
> store
> /// and load/op/cmp case where the root (store / cmp) may reach the  
> load via
> /// its chain operand.
> -static inline bool isNonImmUse(SDNode *Root, SDNode *Def, SDNode  
> *ImmedUse,
> -                               SDNode *Skip = NULL) {
> +static inline bool isNonImmUse(SDNode *Root, SDNode *Def, SDNode  
> *ImmedUse) {
>   SmallPtrSet<SDNode*, 16> Visited;
>   bool found = false;
> -  findNonImmUse(Root, Def, ImmedUse, Root, Skip, found, Visited);
> +  findNonImmUse(Root, Def, ImmedUse, Root, found, Visited);
>   return found;
> }
>
> @@ -321,55 +310,58 @@
> bool X86DAGToDAGISel::CanBeFoldedBy(SDNode *N, SDNode *U, SDNode  
> *Root) const {
>   if (Fast) return false;
>
> -  // If U use can somehow reach N through another path then U can't  
> fold N or
> -  // it will create a cycle. e.g. In the following diagram, U can  
> reach N
> -  // through X. If N is folded into into U, then X is both a  
> predecessor and
> -  // a successor of U.
> +  // If Root use can somehow reach N through a path that that  
> doesn't contain
> +  // U then folding N would create a cycle. e.g. In the following
> +  // diagram, Root can reach N through X. If N is folded into into  
> Root, then
> +  // X is both a predecessor and a successor of U.
>   //
> -  //         [ N ]
> -  //         ^  ^
> -  //         |  |
> -  //        /   \---
> -  //      /        [X]
> -  //      |         ^
> -  //     [U]--------|
> -
> -  if (isNonImmUse(Root, N, U))
> -    return false;
> -
> -  // If U produces a flag, then it gets (even more) interesting.  
> Since it
> -  // would have been "glued" together with its flag use, we need to  
> check if
> -  // it might reach N:
> +  //          [N*]           //
> +  //         ^   ^           //
> +  //        /     \          //
> +  //      [U*]    [X]?       //
> +  //        ^     ^          //
> +  //         \   /           //
> +  //          \ /            //
> +  //         [Root*]         //
>   //
> -  //       [ N ]
> -  //        ^ ^
> -  //        | |
> -  //       [U] \--
> -  //        ^   [TF]
> -  //        |    ^
> -  //        |    |
> -  //         \  /
> -  //          [FU]
> +  // * indicates nodes to be folded together.
>   //
> -  // If FU (flag use) indirectly reach N (the load), and U fold N  
> (call it
> -  // NU), then TF is a predecessor of FU and a successor of NU. But  
> since
> -  // NU and FU are flagged together, this effectively creates a  
> cycle.
> -  bool HasFlagUse = false;
> +  // If Root produces a flag, then it gets (even more) interesting.  
> Since it
> +  // will be "glued" together with its flag use in the scheduler,  
> we need to
> +  // check if it might reach N.
> +  //
> +  //          [N*]           //
> +  //         ^   ^           //
> +  //        /     \          //
> +  //      [U*]    [X]?       //
> +  //        ^       ^        //
> +  //         \       \       //
> +  //          \      |       //
> +  //         [Root*] |       //
> +  //          ^      |       //
> +  //          f      |       //
> +  //          |      /       //
> +  //         [Y]    /        //
> +  //           ^   /         //
> +  //           f  /          //
> +  //           | /           //
> +  //          [FU]           //
> +  //
> +  // If FU (flag use) indirectly reaches N (the load), and Root  
> folds N
> +  // (call it Fold), then X is a predecessor of FU and a successor of
> +  // Fold. But since Fold and FU are flagged together, this will  
> create
> +  // a cycle in the scheduling graph.
> +
>   MVT VT = Root->getValueType(Root->getNumValues()-1);
> -  while ((VT == MVT::Flag && !Root->use_empty())) {
> +  while (VT == MVT::Flag) {
>     SDNode *FU = findFlagUse(Root);
>     if (FU == NULL)
>       break;
> -    else {
> -      Root = FU;
> -      HasFlagUse = true;
> -    }
> +    Root = FU;
>     VT = Root->getValueType(Root->getNumValues()-1);
>   }
>
> -  if (HasFlagUse)
> -    return !isNonImmUse(Root, N, Root, U);
> -  return true;
> +  return !isNonImmUse(Root, N, U);
> }
>
> /// MoveBelowTokenFactor - Replace TokenFactor operand with load's  
> chain operand
>
>
> _______________________________________________
> 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