@@ -142,7 +142,6 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
142
142
void disableSROA (Value *V);
143
143
void accumulateSROACost (DenseMap<Value *, int >::iterator CostIt,
144
144
int InstructionCost);
145
- bool isGEPOffsetConstant (GetElementPtrInst &GEP);
146
145
bool isGEPFree (GetElementPtrInst &GEP);
147
146
bool accumulateGEPOffset (GEPOperator &GEP, APInt &Offset);
148
147
bool simplifyCallSite (Function *F, CallSite CS);
@@ -300,17 +299,6 @@ void CallAnalyzer::accumulateSROACost(DenseMap<Value *, int>::iterator CostIt,
300
299
SROACostSavings += InstructionCost;
301
300
}
302
301
303
- // / \brief Check whether a GEP's indices are all constant.
304
- // /
305
- // / Respects any simplified values known during the analysis of this callsite.
306
- bool CallAnalyzer::isGEPOffsetConstant (GetElementPtrInst &GEP) {
307
- for (User::op_iterator I = GEP.idx_begin (), E = GEP.idx_end (); I != E; ++I)
308
- if (!isa<Constant>(*I) && !SimplifiedValues.lookup (*I))
309
- return false ;
310
-
311
- return true ;
312
- }
313
-
314
302
// / \brief Accumulate a constant GEP offset into an APInt if possible.
315
303
// /
316
304
// / Returns false if unable to compute the offset for any reason. Respects any
@@ -440,7 +428,15 @@ bool CallAnalyzer::visitGetElementPtr(GetElementPtrInst &I) {
440
428
}
441
429
}
442
430
443
- if (isGEPOffsetConstant (I)) {
431
+ // Lambda to check whether a GEP's indices are all constant.
432
+ auto IsGEPOffsetConstant = [&](GetElementPtrInst &GEP) {
433
+ for (User::op_iterator I = GEP.idx_begin (), E = GEP.idx_end (); I != E; ++I)
434
+ if (!isa<Constant>(*I) && !SimplifiedValues.lookup (*I))
435
+ return false ;
436
+ return true ;
437
+ };
438
+
439
+ if (IsGEPOffsetConstant (I)) {
444
440
if (SROACandidate)
445
441
SROAArgValues[&I] = SROAArg;
446
442
0 commit comments