Skip to content

Commit 6d3e64e

Browse files
committed
move check
1 parent 817f8e9 commit 6d3e64e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,12 @@ static bool hoistGEP(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo,
25082508
if (!GEP)
25092509
return false;
25102510

2511+
// Do not try to hoist a constant GEP out of the loop via reassociation.
2512+
// Constant GEPs can often be folded into addressing modes, and reassociating
2513+
// them may inhibit CSE of a common base.
2514+
if (GEP->hasAllConstantIndices())
2515+
return false;
2516+
25112517
auto *Src = dyn_cast<GetElementPtrInst>(GEP->getPointerOperand());
25122518
if (!Src || !Src->hasOneUse() || !L.contains(Src))
25132519
return false;
@@ -2517,12 +2523,6 @@ static bool hoistGEP(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo,
25172523
if (!L.isLoopInvariant(SrcPtr) || !all_of(GEP->indices(), LoopInvariant))
25182524
return false;
25192525

2520-
// Do not try to hoist a constant GEP out of the loop via reassociation.
2521-
// Constant GEPs can often be folded into addressing modes, and reassociating
2522-
// them may inhibit CSE of a common base.
2523-
if (GEP->hasAllConstantIndices())
2524-
return false;
2525-
25262526
// This can only happen if !AllowSpeculation, otherwise this would already be
25272527
// handled.
25282528
// FIXME: Should we respect AllowSpeculation in these reassociation folds?

0 commit comments

Comments
 (0)