mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 02:36:06 +00:00
Fix a bug in GetConstantFactor for affine expressions, in which the existing
code was wrong for things like 3+4*i. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32662 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
49e6a9bc94
commit
75de5ab9f5
@ -74,6 +74,7 @@
|
|||||||
#include "llvm/Support/ConstantRange.h"
|
#include "llvm/Support/ConstantRange.h"
|
||||||
#include "llvm/Support/InstIterator.h"
|
#include "llvm/Support/InstIterator.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/Streams.h"
|
#include "llvm/Support/Streams.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -1372,11 +1373,14 @@ static uint64_t GetConstantFactor(SCEVHandle S) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SCEVAddRecExpr *A = dyn_cast<SCEVAddRecExpr>(S)) {
|
if (SCEVAddRecExpr *A = dyn_cast<SCEVAddRecExpr>(S)) {
|
||||||
// FIXME: Generalize.
|
// For now, we just handle linear expressions.
|
||||||
if (A->getNumOperands() == 2)
|
if (A->getNumOperands() == 2) {
|
||||||
return std::min(GetConstantFactor(A->getOperand(0)),
|
// We want the GCD between the start and the stride value.
|
||||||
GetConstantFactor(A->getOperand(1)));
|
uint64_t Start = GetConstantFactor(A->getOperand(0));
|
||||||
// ?
|
if (Start == 1) return 1;
|
||||||
|
uint64_t Stride = GetConstantFactor(A->getOperand(1));
|
||||||
|
return GreatestCommonDivisor64(Start, Stride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SCEVSDivExpr, SCEVUnknown.
|
// SCEVSDivExpr, SCEVUnknown.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user