diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2009-02-20 22:16:49 +0000 | 
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2009-02-20 22:16:49 +0000 | 
| commit | 8a9481d50df49c773fca5178e8d34a6512a62e64 (patch) | |
| tree | 1168d7041d4df3b191fc93ff6ccc3414299f6e40 /llvm/lib/Transforms | |
| parent | b98f0eb9afaa9d9018153308d72c7aa19e14d884 (diff) | |
| download | bcm5719-llvm-8a9481d50df49c773fca5178e8d34a6512a62e64.tar.gz bcm5719-llvm-8a9481d50df49c773fca5178e8d34a6512a62e64.zip | |
Fix strange logic in CollectIVUsers used to determine whether all uses are
addresses, part 1. This fixes an obvious logic bug. Previously if the only
in-loop use is a PHI, it would return AllUsesAreAddresses as true.
llvm-svn: 65178
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 9 | 
1 files changed, 8 insertions, 1 deletions
| diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index a52b7d0f1c2..d18a008fef0 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1439,6 +1439,7 @@ SCEVHandle LoopStrengthReduce::CollectIVUsers(const SCEVHandle &Stride,    // fields of the BasedUsers.  We do this so that it increases the commonality    // of the remaining uses.    unsigned NumPHI = 0; +  bool HasAddress = false;    for (unsigned i = 0, e = UsersToProcess.size(); i != e; ++i) {      // If the user is not in the current loop, this means it is using the exit      // value of the IV.  Do not put anything in the base, make sure it's all in @@ -1449,7 +1450,6 @@ SCEVHandle LoopStrengthReduce::CollectIVUsers(const SCEVHandle &Stride,        UsersToProcess[i].Base =           SE->getIntegerSCEV(0, UsersToProcess[i].Base->getType());      } else { -        // Addressing modes can be folded into loads and stores.  Be careful that        // the store is through the expression, not of the expression though.        bool isPHI = false; @@ -1462,6 +1462,9 @@ SCEVHandle LoopStrengthReduce::CollectIVUsers(const SCEVHandle &Stride,        // Not all uses are outside the loop.        AllUsesAreOutsideLoop = false;  + +      if (isAddress) +        HasAddress = true;        // If this use isn't an address, then not all uses are addresses.        if (!isAddress && !isPHI) @@ -1478,6 +1481,10 @@ SCEVHandle LoopStrengthReduce::CollectIVUsers(const SCEVHandle &Stride,    if (NumPHI > 1)      AllUsesAreAddresses = false; +  // There are no in-loop address uses. +  if (AllUsesAreAddresses && (!HasAddress && !AllUsesAreOutsideLoop)) +    AllUsesAreAddresses = false; +    return CommonExprs;  } | 

