Skip to content

Commit cde0075

Browse files
committed
fixup! do iff both pointers are used with ptrtoint
1 parent e15465d commit cde0075

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,19 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
6161
? static_cast<uint64_t>(LocB.Size.getValue())
6262
: MemoryLocation::UnknownSize);
6363

64-
// Before calling getMinusSCEV(), we could try the ptrtpoint pointer
65-
// operands so that you can handle two pointers with different pointer
66-
// bases.
64+
// Firstly, try to convert the two pointers into ptrtoint expressions to
65+
// handle two pointers with different pointer bases.
66+
// Either both pointers are used with ptrtoint or neither, so we can't end
67+
// up with a ptr + int mix (not entirely sure whether it's possible for just
68+
// one of the conversions to fail).
6769
const SCEV *AInt =
6870
SE.getPtrToIntExpr(AS, SE.getEffectiveSCEVType(AS->getType()));
69-
if (!isa<SCEVCouldNotCompute>(AInt))
70-
AS = AInt;
7171
const SCEV *BInt =
7272
SE.getPtrToIntExpr(BS, SE.getEffectiveSCEVType(BS->getType()));
73-
if (!isa<SCEVCouldNotCompute>(BInt))
73+
if (!isa<SCEVCouldNotCompute>(AInt) && !isa<SCEVCouldNotCompute>(BInt)) {
74+
AS = AInt;
7475
BS = BInt;
76+
}
7577

7678
// Compute the difference between the two pointers.
7779
const SCEV *BA = SE.getMinusSCEV(BS, AS);

0 commit comments

Comments
 (0)