Skip to content

Commit 40ffe9c

Browse files
author
Zain Jaffal
committed
[ConstraintElimination] Move Value2Index map to ConstraintSystem (NFC)
Differential Revision: https://reviews.llvm.org/D142647
1 parent b83caa3 commit 40ffe9c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

llvm/include/llvm/Analysis/ConstraintSystem.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@
1111

1212
#include "llvm/ADT/APInt.h"
1313
#include "llvm/ADT/ArrayRef.h"
14+
#include "llvm/ADT/DenseMap.h"
1415
#include "llvm/ADT/SmallVector.h"
1516

1617
#include <string>
1718

1819
namespace llvm {
19-
20+
class Value;
2021
class ConstraintSystem {
2122
/// Current linear constraints in the system.
2223
/// An entry of the form c0, c1, ... cn represents the following constraint:
2324
/// c0 >= v0 * c1 + .... + v{n-1} * cn
2425
SmallVector<SmallVector<int64_t, 8>, 4> Constraints;
2526

27+
/// a Map between variabled collected in ConstraintElimination and their
28+
/// corresponding index in the constraint system solver.
29+
DenseMap<Value *, unsigned> Value2Index;
30+
2631
/// Current greatest common divisor for all coefficients in the system.
2732
uint32_t GCD = 1;
2833

@@ -52,6 +57,11 @@ class ConstraintSystem {
5257
return true;
5358
}
5459

60+
DenseMap<Value *, unsigned> &getValue2Index() { return Value2Index; }
61+
const DenseMap<Value *, unsigned> &getValue2Index() const {
62+
return Value2Index;
63+
}
64+
5565
bool addVariableRowFill(ArrayRef<int64_t> R) {
5666
// If all variable coefficients are 0, the constraint does not provide any
5767
// usable information.

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ struct ConstraintTy {
123123
/// based on signed-ness, certain conditions can be transferred between the two
124124
/// systems.
125125
class ConstraintInfo {
126-
DenseMap<Value *, unsigned> UnsignedValue2Index;
127-
DenseMap<Value *, unsigned> SignedValue2Index;
128126

129127
ConstraintSystem UnsignedCS;
130128
ConstraintSystem SignedCS;
@@ -135,10 +133,10 @@ class ConstraintInfo {
135133
ConstraintInfo(const DataLayout &DL) : DL(DL) {}
136134

137135
DenseMap<Value *, unsigned> &getValue2Index(bool Signed) {
138-
return Signed ? SignedValue2Index : UnsignedValue2Index;
136+
return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index();
139137
}
140138
const DenseMap<Value *, unsigned> &getValue2Index(bool Signed) const {
141-
return Signed ? SignedValue2Index : UnsignedValue2Index;
139+
return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index();
142140
}
143141

144142
ConstraintSystem &getCS(bool Signed) {

0 commit comments

Comments
 (0)