mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 19:25:00 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65178 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user