Skip to content

Commit 17355e5

Browse files
committed
[GVN] Replace PointerIntPair with separate pointer & kind fields (NFC).
After adding another value kind in 8a12cae, Value * pointers do not have enough available empty bits to store the kind (e.g. on ARM) To address this, the patch replaces the PointerIntPair with separate value and kind fields. (cherry-picked from 1c9f154)
1 parent 23ef75b commit 17355e5

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ template <> struct DenseMapInfo<GVN::Expression> {
177177
/// implicitly associated with a rematerialization point which is the
178178
/// location of the instruction from which it was formed.
179179
struct llvm::gvn::AvailableValue {
180-
enum ValType {
180+
enum class ValType {
181181
SimpleVal, // A simple offsetted value that is accessed.
182182
LoadVal, // A value produced by a load.
183183
MemIntrin, // A memory intrinsic which is loaded from.
@@ -187,76 +187,78 @@ struct llvm::gvn::AvailableValue {
187187
// can be replace by a value select.
188188
};
189189

190-
/// V - The value that is live out of the block.
191-
PointerIntPair<Value *, 3, ValType> Val;
190+
/// Val - The value that is live out of the block.
191+
Value *Val;
192+
/// Kind of the live-out value.
193+
ValType Kind;
192194

193195
/// Offset - The byte offset in Val that is interesting for the load query.
194196
unsigned Offset = 0;
195197

196198
static AvailableValue get(Value *V, unsigned Offset = 0) {
197199
AvailableValue Res;
198-
Res.Val.setPointer(V);
199-
Res.Val.setInt(SimpleVal);
200+
Res.Val = V;
201+
Res.Kind = ValType::SimpleVal;
200202
Res.Offset = Offset;
201203
return Res;
202204
}
203205

204206
static AvailableValue getMI(MemIntrinsic *MI, unsigned Offset = 0) {
205207
AvailableValue Res;
206-
Res.Val.setPointer(MI);
207-
Res.Val.setInt(MemIntrin);
208+
Res.Val = MI;
209+
Res.Kind = ValType::MemIntrin;
208210
Res.Offset = Offset;
209211
return Res;
210212
}
211213

212214
static AvailableValue getLoad(LoadInst *Load, unsigned Offset = 0) {
213215
AvailableValue Res;
214-
Res.Val.setPointer(Load);
215-
Res.Val.setInt(LoadVal);
216+
Res.Val = Load;
217+
Res.Kind = ValType::LoadVal;
216218
Res.Offset = Offset;
217219
return Res;
218220
}
219221

220222
static AvailableValue getUndef() {
221223
AvailableValue Res;
222-
Res.Val.setPointer(nullptr);
223-
Res.Val.setInt(UndefVal);
224+
Res.Val = nullptr;
225+
Res.Kind = ValType::UndefVal;
224226
Res.Offset = 0;
225227
return Res;
226228
}
227229

228230
static AvailableValue getSelect(SelectInst *Sel) {
229231
AvailableValue Res;
230-
Res.Val.setPointer(Sel);
231-
Res.Val.setInt(SelectVal);
232+
Res.Val = Sel;
233+
Res.Kind = ValType::SelectVal;
232234
Res.Offset = 0;
233235
return Res;
234236
}
235237

236-
bool isSimpleValue() const { return Val.getInt() == SimpleVal; }
237-
bool isCoercedLoadValue() const { return Val.getInt() == LoadVal; }
238-
bool isMemIntrinValue() const { return Val.getInt() == MemIntrin; }
239-
bool isUndefValue() const { return Val.getInt() == UndefVal; }
240-
bool isSelectValue() const { return Val.getInt() == SelectVal; }
238+
bool isSimpleValue() const { return Kind == ValType::SimpleVal; }
239+
bool isCoercedLoadValue() const { return Kind == ValType::LoadVal; }
240+
bool isMemIntrinValue() const { return Kind == ValType::MemIntrin; }
241+
bool isUndefValue() const { return Kind == ValType::UndefVal; }
242+
bool isSelectValue() const { return Kind == ValType::SelectVal; }
241243

242244
Value *getSimpleValue() const {
243245
assert(isSimpleValue() && "Wrong accessor");
244-
return Val.getPointer();
246+
return Val;
245247
}
246248

247249
LoadInst *getCoercedLoadValue() const {
248250
assert(isCoercedLoadValue() && "Wrong accessor");
249-
return cast<LoadInst>(Val.getPointer());
251+
return cast<LoadInst>(Val);
250252
}
251253

252254
MemIntrinsic *getMemIntrinValue() const {
253255
assert(isMemIntrinValue() && "Wrong accessor");
254-
return cast<MemIntrinsic>(Val.getPointer());
256+
return cast<MemIntrinsic>(Val);
255257
}
256258

257259
SelectInst *getSelectValue() const {
258260
assert(isSelectValue() && "Wrong accessor");
259-
return cast<SelectInst>(Val.getPointer());
261+
return cast<SelectInst>(Val);
260262
}
261263

262264
/// Emit code at the specified insertion point to adjust the value defined

0 commit comments

Comments
 (0)