@@ -117,8 +117,12 @@ bool GISelAddressing::aliasIsKnownForLoadStore(const MachineInstr &MI1,
117
117
if (!BasePtr0.BaseReg .isValid () || !BasePtr1.BaseReg .isValid ())
118
118
return false ;
119
119
120
- int64_t Size1 = LdSt1->getMemSize ();
121
- int64_t Size2 = LdSt2->getMemSize ();
120
+ LocationSize Size1 = LdSt1->getMemSize () != MemoryLocation::UnknownSize
121
+ ? LdSt1->getMemSize ()
122
+ : LocationSize::beforeOrAfterPointer ();
123
+ LocationSize Size2 = LdSt2->getMemSize () != MemoryLocation::UnknownSize
124
+ ? LdSt2->getMemSize ()
125
+ : LocationSize::beforeOrAfterPointer ();
122
126
123
127
int64_t PtrDiff;
124
128
if (BasePtr0.BaseReg == BasePtr1.BaseReg ) {
@@ -128,20 +132,18 @@ bool GISelAddressing::aliasIsKnownForLoadStore(const MachineInstr &MI1,
128
132
// vector objects on the stack.
129
133
// BasePtr1 is PtrDiff away from BasePtr0. They alias if none of the
130
134
// following situations arise:
131
- if (PtrDiff >= 0 &&
132
- Size1 != static_cast <int64_t >(MemoryLocation::UnknownSize)) {
135
+ if (PtrDiff >= 0 && Size1.hasValue ()) {
133
136
// [----BasePtr0----]
134
137
// [---BasePtr1--]
135
138
// ========PtrDiff========>
136
- IsAlias = !(Size1 <= PtrDiff);
139
+ IsAlias = !(( int64_t ) Size1. getValue () <= PtrDiff);
137
140
return true ;
138
141
}
139
- if (PtrDiff < 0 &&
140
- Size2 != static_cast <int64_t >(MemoryLocation::UnknownSize)) {
142
+ if (PtrDiff < 0 && Size2.hasValue ()) {
141
143
// [----BasePtr0----]
142
144
// [---BasePtr1--]
143
145
// =====(-PtrDiff)====>
144
- IsAlias = !((PtrDiff + Size2) <= 0 );
146
+ IsAlias = !((PtrDiff + ( int64_t ) Size2. getValue () ) <= 0 );
145
147
return true ;
146
148
}
147
149
return false ;
@@ -196,7 +198,7 @@ bool GISelAddressing::instMayAlias(const MachineInstr &MI,
196
198
bool IsAtomic;
197
199
Register BasePtr;
198
200
int64_t Offset;
199
- uint64_t NumBytes;
201
+ LocationSize NumBytes;
200
202
MachineMemOperand *MMO;
201
203
};
202
204
@@ -212,16 +214,22 @@ bool GISelAddressing::instMayAlias(const MachineInstr &MI,
212
214
Offset = 0 ;
213
215
}
214
216
215
- uint64_t Size = MemoryLocation::getSizeOrUnknown (
216
- LS->getMMO ().getMemoryType ().getSizeInBytes ());
217
- return {LS->isVolatile (), LS->isAtomic (), BaseReg,
218
- Offset /* base offset*/ , Size , &LS->getMMO ()};
217
+ TypeSize Size = LS->getMMO ().getMemoryType ().getSizeInBytes ();
218
+ return {LS->isVolatile (),
219
+ LS->isAtomic (),
220
+ BaseReg,
221
+ Offset /* base offset*/ ,
222
+ Size .isScalable () ? LocationSize::beforeOrAfterPointer ()
223
+ : LocationSize::precise (Size ),
224
+ &LS->getMMO ()};
219
225
}
220
226
// FIXME: support recognizing lifetime instructions.
221
227
// Default.
222
228
return {false /* isvolatile*/ ,
223
- /* isAtomic*/ false , Register (),
224
- (int64_t )0 /* offset*/ , 0 /* size*/ ,
229
+ /* isAtomic*/ false ,
230
+ Register (),
231
+ (int64_t )0 /* offset*/ ,
232
+ LocationSize::beforeOrAfterPointer () /* size*/ ,
225
233
(MachineMemOperand *)nullptr };
226
234
};
227
235
MemUseCharacteristics MUC0 = getCharacteristics (&MI),
@@ -262,15 +270,14 @@ bool GISelAddressing::instMayAlias(const MachineInstr &MI,
262
270
// FIXME: port the alignment based alias analysis from SDAG's isAlias().
263
271
int64_t SrcValOffset0 = MUC0.MMO ->getOffset ();
264
272
int64_t SrcValOffset1 = MUC1.MMO ->getOffset ();
265
- uint64_t Size0 = MUC0.NumBytes ;
266
- uint64_t Size1 = MUC1.NumBytes ;
267
- if (AA && MUC0.MMO ->getValue () && MUC1.MMO ->getValue () &&
268
- Size0 != MemoryLocation::UnknownSize &&
269
- Size1 != MemoryLocation::UnknownSize) {
273
+ LocationSize Size0 = MUC0.NumBytes ;
274
+ LocationSize Size1 = MUC1.NumBytes ;
275
+ if (AA && MUC0.MMO ->getValue () && MUC1.MMO ->getValue () && Size0.hasValue () &&
276
+ Size1.hasValue ()) {
270
277
// Use alias analysis information.
271
278
int64_t MinOffset = std::min (SrcValOffset0, SrcValOffset1);
272
- int64_t Overlap0 = Size0 + SrcValOffset0 - MinOffset;
273
- int64_t Overlap1 = Size1 + SrcValOffset1 - MinOffset;
279
+ int64_t Overlap0 = Size0. getValue () + SrcValOffset0 - MinOffset;
280
+ int64_t Overlap1 = Size1. getValue () + SrcValOffset1 - MinOffset;
274
281
if (AA->isNoAlias (MemoryLocation (MUC0.MMO ->getValue (), Overlap0,
275
282
MUC0.MMO ->getAAInfo ()),
276
283
MemoryLocation (MUC1.MMO ->getValue (), Overlap1,
0 commit comments