Skip to content

Commit af6cc8f

Browse files
committed
Restore inbounds check
1 parent d3f9de6 commit af6cc8f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
448448
return false;
449449

450450
if (auto *GEP = dyn_cast<GEPOperator>(V)) {
451-
// Only allow GEPs with at most one variable offset.
451+
// Only allow inbounds GEPs with at most one variable offset.
452452
auto IsNonConst = [](Value *V) { return !isa<ConstantInt>(V); };
453-
if (count_if(GEP->indices(), IsNonConst) > 1)
453+
if (!GEP->isInBounds() || count_if(GEP->indices(), IsNonConst) > 1)
454454
return false;
455455

456456
if (!Explored.contains(GEP->getOperand(0)))

0 commit comments

Comments
 (0)