Skip to content

Commit a9d6a86

Browse files
author
Zain Jaffal
committed
Recommit "[ConstraintElimination] Move Value2Index map to ConstraintSystem (NFC)"
This reverts commit 665ee0c. Fix comments and formatting style.
1 parent 22a5593 commit a9d6a86

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

llvm/include/llvm/Analysis/ConstraintSystem.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,25 @@
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 {
1920

21+
class Value;
22+
2023
class ConstraintSystem {
2124
/// Current linear constraints in the system.
2225
/// An entry of the form c0, c1, ... cn represents the following constraint:
2326
/// c0 >= v0 * c1 + .... + v{n-1} * cn
2427
SmallVector<SmallVector<int64_t, 8>, 4> Constraints;
2528

29+
/// A map of variables (IR values) to their corresponding index in the
30+
/// constraint system.
31+
DenseMap<Value *, unsigned> Value2Index;
32+
2633
/// Current greatest common divisor for all coefficients in the system.
2734
uint32_t GCD = 1;
2835

@@ -52,6 +59,11 @@ class ConstraintSystem {
5259
return true;
5360
}
5461

62+
DenseMap<Value *, unsigned> &getValue2Index() { return Value2Index; }
63+
const DenseMap<Value *, unsigned> &getValue2Index() const {
64+
return Value2Index;
65+
}
66+
5567
bool addVariableRowFill(ArrayRef<int64_t> R) {
5668
// If all variable coefficients are 0, the constraint does not provide any
5769
// 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)