llvm.org GIT mirror llvm / ccb51b9
[BasicAA] Support arbitrary pointer sizes (and fix an overflow bug) Motivated by the discussion in D38499, this patch updates BasicAA to support arbitrary pointer sizes by switching most remaining non-APInt calculations to use APInt. The size of these APInts is set to the maximum pointer size (maximum over all address spaces described by the data layout string). Most of this translation is straightforward, but this patch contains a fix for a bug that revealed itself during this translation process. In order for test/Analysis/BasicAA/gep-and-alias.ll to pass, which is run with 32-bit pointers, the intermediate calculations must be performed using 64-bit integers. This is because, as noted in the patch, when GetLinearExpression decomposes an expression into C1*V+C2, and we then multiply this by Scale, and distribute, to get (C1*Scale)*V + C2*Scale, it can be the case that, even through C1*V+C2 does not overflow for relevant values of V, (C2*Scale) can overflow. If this happens, later logic will draw invalid conclusions from the (base) offset value. Thus, when initially applying the APInt conversion, because the maximum pointer size in this test is 32 bits, it started failing. Suspicious, I created a 64-bit version of this test (included here), and that failed (miscompiled) on trunk for a similar reason (the multiplication can overflow). After fixing this overflow bug, the first test case (at least) in Analysis/BasicAA/q.bad.ll started failing. This is also a 32-bit test, and was relying on having 64-bit intermediate values to have BasicAA return an accurate result. In order to fix this problem, and because I believe that it is not uncommon to use i64 indexing expressions in 32-bit code (especially portable code using int64_t), it seems reasonable to always use at least 64-bit integers. In this way, we won't regress our analysis capabilities (and there's a command-line option added, so experimenting with this should be easy). As pointed out by Eli during the review, there are other potential overflow conditions that this patch does not address. Fixing those is left to follow-up work. Patch by me with contributions from Michael Ferguson (mferguson@cray.com). Differential Revision: https://reviews.llvm.org/D38662 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350220 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 1 year, 4 months ago
7 changed file(s) with 220 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
114114 unsigned ZExtBits;
115115 unsigned SExtBits;
116116
117 int64_t Scale;
117 APInt Scale;
118118
119119 bool operator==(const VariableGEPIndex &Other) const {
120120 return V == Other.V && ZExtBits == Other.ZExtBits &&
132132 // Base pointer of the GEP
133133 const Value *Base;
134134 // Total constant offset w.r.t the base from indexing into structs
135 int64_t StructOffset;
135 APInt StructOffset;
136136 // Total constant offset w.r.t the base from indexing through
137137 // pointers/arrays/vectors
138 int64_t OtherOffset;
138 APInt OtherOffset;
139139 // Scaled variable (non-constant) indices.
140140 SmallVector VarIndices;
141141 };
188188 bool
189189 constantOffsetHeuristic(const SmallVectorImpl &VarIndices,
190190 LocationSize V1Size, LocationSize V2Size,
191 int64_t BaseOffset, AssumptionCache *AC,
191 APInt BaseOffset, AssumptionCache *AC,
192192 DominatorTree *DT);
193193
194194 bool isValueEqualInPotentialCycles(const Value *V1, const Value *V2);
333333 /// the backends/clients are updated.
334334 unsigned getPointerSize(unsigned AS = 0) const;
335335
336 /// Returns the maximum pointer size over all address spaces.
337 unsigned getMaxPointerSize() const;
338
336339 // Index size used for address calculation.
337340 unsigned getIndexSize(unsigned AS) const;
338341
358361 /// the backends/clients are updated.
359362 unsigned getPointerSizeInBits(unsigned AS = 0) const {
360363 return getPointerSize(AS) * 8;
364 }
365
366 /// Returns the maximum pointer size over all address spaces.
367 unsigned getMaxPointerSizeInBits() const {
368 return getMaxPointerSize() * 8;
361369 }
362370
363371 /// Size in bits of index used for address calculation in getelementptr.
6767 /// Enable analysis of recursive PHI nodes.
6868 static cl::opt EnableRecPhiAnalysis("basicaa-recphi", cl::Hidden,
6969 cl::init(false));
70
71 /// By default, even on 32-bit architectures we use 64-bit integers for
72 /// calculations. This will allow us to more-aggressively decompose indexing
73 /// expressions calculated using i64 values (e.g., long long in C) which is
74 /// common enough to worry about.
75 static cl::opt ForceAtLeast64Bits("basicaa-force-at-least-64b",
76 cl::Hidden, cl::init(true));
77 static cl::opt DoubleCalcBits("basicaa-double-calc-bits",
78 cl::Hidden, cl::init(false));
79
7080 /// SearchLimitReached / SearchTimes shows how often the limit of
7181 /// to decompose GEPs is reached. It will affect the precision
7282 /// of basic alias analysis.
380390 }
381391
382392 /// To ensure a pointer offset fits in an integer of size PointerSize
383 /// (in bits) when that size is smaller than 64. This is an issue in
384 /// particular for 32b programs with negative indices that rely on two's
385 /// complement wrap-arounds for precise alias information.
386 static int64_t adjustToPointerSize(int64_t Offset, unsigned PointerSize) {
387 assert(PointerSize <= 64 && "Invalid PointerSize!");
388 unsigned ShiftBits = 64 - PointerSize;
389 return (int64_t)((uint64_t)Offset << ShiftBits) >> ShiftBits;
393 /// (in bits) when that size is smaller than the maximum pointer size. This is
394 /// an issue, for example, in particular for 32b pointers with negative indices
395 /// that rely on two's complement wrap-arounds for precise alias information
396 /// where the maximum pointer size is 64b.
397 static APInt adjustToPointerSize(APInt Offset, unsigned PointerSize) {
398 assert(PointerSize <= Offset.getBitWidth() && "Invalid PointerSize!");
399 unsigned ShiftBits = Offset.getBitWidth() - PointerSize;
400 return (Offset << ShiftBits).ashr(ShiftBits);
401 }
402
403 static unsigned getMaxPointerSize(const DataLayout &DL) {
404 unsigned MaxPointerSize = DL.getMaxPointerSizeInBits();
405 if (MaxPointerSize < 64 && ForceAtLeast64Bits) MaxPointerSize = 64;
406 if (DoubleCalcBits) MaxPointerSize *= 2;
407
408 return MaxPointerSize;
390409 }
391410
392411 /// If V is a symbolic pointer expression, decompose it into a base pointer
409428 unsigned MaxLookup = MaxLookupSearchDepth;
410429 SearchTimes++;
411430
412 Decomposed.StructOffset = 0;
413 Decomposed.OtherOffset = 0;
431 unsigned MaxPointerSize = getMaxPointerSize(DL);
414432 Decomposed.VarIndices.clear();
415433 do {
416434 // See if this is a bitcast or GEP.
500518 if (CIdx->isZero())
501519 continue;
502520 Decomposed.OtherOffset +=
503 DL.getTypeAllocSize(GTI.getIndexedType()) * CIdx->getSExtValue();
521 (DL.getTypeAllocSize(GTI.getIndexedType()) *
522 CIdx->getValue().sextOrSelf(MaxPointerSize))
523 .sextOrTrunc(MaxPointerSize);
504524 continue;
505525 }
506526
507527 GepHasConstantOffset = false;
508528
509 uint64_t Scale = DL.getTypeAllocSize(GTI.getIndexedType());
529 APInt Scale(MaxPointerSize, DL.getTypeAllocSize(GTI.getIndexedType()));
510530 unsigned ZExtBits = 0, SExtBits = 0;
511531
512532 // If the integer type is smaller than the pointer size, it is implicitly
518538 // Use GetLinearExpression to decompose the index into a C1*V+C2 form.
519539 APInt IndexScale(Width, 0), IndexOffset(Width, 0);
520540 bool NSW = true, NUW = true;
541 const Value *OrigIndex = Index;
521542 Index = GetLinearExpression(Index, IndexScale, IndexOffset, ZExtBits,
522543 SExtBits, DL, 0, AC, DT, NSW, NUW);
523544
524 // All GEP math happens in the width of the pointer type,
525 // so we can truncate the value to 64-bits as we don't handle
526 // currently pointers larger than 64 bits and we would crash
527 // later. TODO: Make `Scale` an APInt to avoid this problem.
528 if (IndexScale.getBitWidth() > 64)
529 IndexScale = IndexScale.sextOrTrunc(64);
530
531545 // The GEP index scale ("Scale") scales C1*V+C2, yielding (C1*V+C2)*Scale.
532546 // This gives us an aggregate computation of (C1*Scale)*V + C2*Scale.
533 Decomposed.OtherOffset += IndexOffset.getSExtValue() * Scale;
534 Scale *= IndexScale.getSExtValue();
547
548 // It can be the case that, even through C1*V+C2 does not overflow for
549 // relevant values of V, (C2*Scale) can overflow. In that case, we cannot
550 // decompose the expression in this way.
551 //
552 // FIXME: C1*Scale and the other operations in the decomposed
553 // (C1*Scale)*V+C2*Scale can also overflow. We should check for this
554 // possibility.
555 APInt WideScaledOffset = IndexOffset.sextOrTrunc(MaxPointerSize*2) *
556 Scale.sext(MaxPointerSize*2);
557 if (WideScaledOffset.getMinSignedBits() > MaxPointerSize) {
558 Index = OrigIndex;
559 IndexScale = 1;
560 IndexOffset = 0;
561
562 ZExtBits = SExtBits = 0;
563 if (PointerSize > Width)
564 SExtBits += PointerSize - Width;
565 } else {
566 Decomposed.OtherOffset += IndexOffset.sextOrTrunc(MaxPointerSize) * Scale;
567 Scale *= IndexScale.sextOrTrunc(MaxPointerSize);
568 }
535569
536570 // If we already had an occurrence of this index variable, merge this
537571 // scale into it. For example, we want to handle:
551585 // pointer size.
552586 Scale = adjustToPointerSize(Scale, PointerSize);
553587
554 if (Scale) {
555 VariableGEPIndex Entry = {Index, ZExtBits, SExtBits,
556 static_cast(Scale)};
588 if (!!Scale) {
589 VariableGEPIndex Entry = {Index, ZExtBits, SExtBits, Scale};
557590 Decomposed.VarIndices.push_back(Entry);
558591 }
559592 }
10381071
10391072 // If the last (struct) indices are constants and are equal, the other indices
10401073 // might be also be dynamically equal, so the GEPs can alias.
1041 if (C1 && C2 && C1->getSExtValue() == C2->getSExtValue())
1042 return MayAlias;
1074 if (C1 && C2) {
1075 unsigned BitWidth = std::max(C1->getBitWidth(), C2->getBitWidth());
1076 if (C1->getValue().sextOrSelf(BitWidth) ==
1077 C2->getValue().sextOrSelf(BitWidth))
1078 return MayAlias;
1079 }
10431080
10441081 // Find the last-indexed type of the GEP, i.e., the type you'd get if
10451082 // you stripped the last index.
11211158 } else if (!LastIndexedStruct || !C1 || !C2) {
11221159 return MayAlias;
11231160 }
1161
1162 if (C1->getValue().getActiveBits() > 64 ||
1163 C2->getValue().getActiveBits() > 64)
1164 return MayAlias;
11241165
11251166 // We know that:
11261167 // - both GEPs begin indexing from the exact same pointer;
12021243 !DecompObject.VarIndices.empty())
12031244 return false;
12041245
1205 int64_t ObjectBaseOffset = DecompObject.StructOffset +
1206 DecompObject.OtherOffset;
1246 APInt ObjectBaseOffset = DecompObject.StructOffset +
1247 DecompObject.OtherOffset;
12071248
12081249 // If the GEP has no variable indices, we know the precise offset
12091250 // from the base, then use it. If the GEP has variable indices,
12111252 // false in that case.
12121253 if (!DecompGEP.VarIndices.empty())
12131254 return false;
1214 int64_t GEPBaseOffset = DecompGEP.StructOffset;
1255
1256 APInt GEPBaseOffset = DecompGEP.StructOffset;
12151257 GEPBaseOffset += DecompGEP.OtherOffset;
12161258
1217 return (GEPBaseOffset >= ObjectBaseOffset + (int64_t)ObjectAccessSize);
1259 return GEPBaseOffset.sge(ObjectBaseOffset + (int64_t)ObjectAccessSize);
12181260 }
12191261
12201262 /// Provides a bunch of ad-hoc rules to disambiguate a GEP instruction against
12291271 LocationSize V2Size, const AAMDNodes &V2AAInfo,
12301272 const Value *UnderlyingV1, const Value *UnderlyingV2) {
12311273 DecomposedGEP DecompGEP1, DecompGEP2;
1274 unsigned MaxPointerSize = getMaxPointerSize(DL);
1275 DecompGEP1.StructOffset = DecompGEP1.OtherOffset = APInt(MaxPointerSize, 0);
1276 DecompGEP2.StructOffset = DecompGEP2.OtherOffset = APInt(MaxPointerSize, 0);
1277
12321278 bool GEP1MaxLookupReached =
12331279 DecomposeGEPExpression(GEP1, DecompGEP1, DL, &AC, DT);
12341280 bool GEP2MaxLookupReached =
12351281 DecomposeGEPExpression(V2, DecompGEP2, DL, &AC, DT);
12361282
1237 int64_t GEP1BaseOffset = DecompGEP1.StructOffset + DecompGEP1.OtherOffset;
1238 int64_t GEP2BaseOffset = DecompGEP2.StructOffset + DecompGEP2.OtherOffset;
1283 APInt GEP1BaseOffset = DecompGEP1.StructOffset + DecompGEP1.OtherOffset;
1284 APInt GEP2BaseOffset = DecompGEP2.StructOffset + DecompGEP2.OtherOffset;
12391285
12401286 assert(DecompGEP1.Base == UnderlyingV1 && DecompGEP2.Base == UnderlyingV2 &&
12411287 "DecomposeGEPExpression returned a result different from "
13531399 // that the objects are partially overlapping. If the difference is
13541400 // greater, we know they do not overlap.
13551401 if (GEP1BaseOffset != 0 && DecompGEP1.VarIndices.empty()) {
1356 if (GEP1BaseOffset >= 0) {
1402 if (GEP1BaseOffset.sge(0)) {
13571403 if (V2Size != LocationSize::unknown()) {
1358 if ((uint64_t)GEP1BaseOffset < V2Size.getValue())
1404 if (GEP1BaseOffset.ult(V2Size.getValue()))
13591405 return PartialAlias;
13601406 return NoAlias;
13611407 }
13701416 // stripped a gep with negative index ('gep , -1, ...).
13711417 if (V1Size != LocationSize::unknown() &&
13721418 V2Size != LocationSize::unknown()) {
1373 if (-(uint64_t)GEP1BaseOffset < V1Size.getValue())
1419 if ((-GEP1BaseOffset).ult(V1Size.getValue()))
13741420 return PartialAlias;
13751421 return NoAlias;
13761422 }
13781424 }
13791425
13801426 if (!DecompGEP1.VarIndices.empty()) {
1381 uint64_t Modulo = 0;
1427 APInt Modulo(MaxPointerSize, 0);
13821428 bool AllPositive = true;
13831429 for (unsigned i = 0, e = DecompGEP1.VarIndices.size(); i != e; ++i) {
13841430
13861432 // Grab the least significant bit set in any of the scales. We
13871433 // don't need std::abs here (even if the scale's negative) as we'll
13881434 // be ^'ing Modulo with itself later.
1389 Modulo |= (uint64_t)DecompGEP1.VarIndices[i].Scale;
1435 Modulo |= DecompGEP1.VarIndices[i].Scale;
13901436
13911437 if (AllPositive) {
13921438 // If the Value could change between cycles, then any reasoning about
14071453 // If the variable begins with a zero then we know it's
14081454 // positive, regardless of whether the value is signed or
14091455 // unsigned.
1410 int64_t Scale = DecompGEP1.VarIndices[i].Scale;
1456 APInt Scale = DecompGEP1.VarIndices[i].Scale;
14111457 AllPositive =
1412 (SignKnownZero && Scale >= 0) || (SignKnownOne && Scale < 0);
1458 (SignKnownZero && Scale.sge(0)) || (SignKnownOne && Scale.slt(0));
14131459 }
14141460 }
14151461
14181464 // We can compute the difference between the two addresses
14191465 // mod Modulo. Check whether that difference guarantees that the
14201466 // two locations do not alias.
1421 uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1);
1467 APInt ModOffset = GEP1BaseOffset & (Modulo - 1);
14221468 if (V1Size != LocationSize::unknown() &&
1423 V2Size != LocationSize::unknown() && ModOffset >= V2Size.getValue() &&
1424 V1Size.getValue() <= Modulo - ModOffset)
1469 V2Size != LocationSize::unknown() && ModOffset.uge(V2Size.getValue()) &&
1470 (Modulo - ModOffset).uge(V1Size.getValue()))
14251471 return NoAlias;
14261472
14271473 // If we know all the variables are positive, then GEP1 >= GEP1BasePtr.
14281474 // If GEP1BasePtr > V2 (GEP1BaseOffset > 0) then we know the pointers
14291475 // don't alias if V2Size can fit in the gap between V2 and GEP1BasePtr.
1430 if (AllPositive && GEP1BaseOffset > 0 &&
1476 if (AllPositive && GEP1BaseOffset.sgt(0) &&
14311477 V2Size != LocationSize::unknown() &&
1432 V2Size.getValue() <= (uint64_t)GEP1BaseOffset)
1478 GEP1BaseOffset.uge(V2Size.getValue()))
14331479 return NoAlias;
14341480
14351481 if (constantOffsetHeuristic(DecompGEP1.VarIndices, V1Size, V2Size,
18351881 for (unsigned i = 0, e = Src.size(); i != e; ++i) {
18361882 const Value *V = Src[i].V;
18371883 unsigned ZExtBits = Src[i].ZExtBits, SExtBits = Src[i].SExtBits;
1838 int64_t Scale = Src[i].Scale;
1884 APInt Scale = Src[i].Scale;
18391885
18401886 // Find V in Dest. This is N^2, but pointer indices almost never have more
18411887 // than a few variable indexes.
18551901 }
18561902
18571903 // If we didn't consume this entry, add it to the end of the Dest list.
1858 if (Scale) {
1904 if (!!Scale) {
18591905 VariableGEPIndex Entry = {V, ZExtBits, SExtBits, -Scale};
18601906 Dest.push_back(Entry);
18611907 }
18641910
18651911 bool BasicAAResult::constantOffsetHeuristic(
18661912 const SmallVectorImpl &VarIndices,
1867 LocationSize MaybeV1Size, LocationSize MaybeV2Size, int64_t BaseOffset,
1913 LocationSize MaybeV1Size, LocationSize MaybeV2Size, APInt BaseOffset,
18681914 AssumptionCache *AC, DominatorTree *DT) {
18691915 if (VarIndices.size() != 2 || MaybeV1Size == LocationSize::unknown() ||
18701916 MaybeV2Size == LocationSize::unknown())
19091955 // the minimum distance between %i and %i + 5 is 3.
19101956 APInt MinDiff = V0Offset - V1Offset, Wrapped = -MinDiff;
19111957 MinDiff = APIntOps::umin(MinDiff, Wrapped);
1912 uint64_t MinDiffBytes = MinDiff.getZExtValue() * std::abs(Var0.Scale);
1958 APInt MinDiffBytes =
1959 MinDiff.zextOrTrunc(Var0.Scale.getBitWidth()) * Var0.Scale.abs();
19131960
19141961 // We can't definitely say whether GEP1 is before or after V2 due to wrapping
19151962 // arithmetic (i.e. for some values of GEP1 and V2 GEP1 < V2, and for other
19161963 // values GEP1 > V2). We'll therefore only declare NoAlias if both V1Size and
19171964 // V2Size can fit in the MinDiffBytes gap.
1918 return V1Size + std::abs(BaseOffset) <= MinDiffBytes &&
1919 V2Size + std::abs(BaseOffset) <= MinDiffBytes;
1965 return MinDiffBytes.uge(V1Size + BaseOffset.abs()) &&
1966 MinDiffBytes.uge(V2Size + BaseOffset.abs());
19201967 }
19211968
19221969 //===----------------------------------------------------------------------===//
634634 return I->TypeByteWidth;
635635 }
636636
637 unsigned DataLayout::getMaxPointerSize() const {
638 unsigned MaxPointerSize = 0;
639 for (auto &P : Pointers)
640 MaxPointerSize = std::max(MaxPointerSize, P.TypeByteWidth);
641
642 return MaxPointerSize;
643 }
644
637645 unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const {
638646 assert(Ty->isPtrOrPtrVectorTy() &&
639647 "This should only be called with a pointer or pointer vector type");
0 ; This testcase consists of alias relations on 128-bit pointers that
1 ; should be completely resolvable by basicaa.
2
3 ; RUN: opt < %s -basicaa -aa-eval -print-no-aliases -print-may-aliases -print-must-aliases -disable-output 2>&1 | FileCheck %s
4
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128-p100:128:64:64-p101:128:64:64"
6
7
8 ; test0 is similar to SimpleCases.ll
9
10 %T = type { i32, [10 x i8] }
11
12 ; CHECK: Function: test0
13 ; CHECK-NOT: MayAlias:
14 define void @test0(%T addrspace(100)* %P) {
15 %A = getelementptr %T, %T addrspace(100)* %P, i64 0
16 %B = getelementptr %T, %T addrspace(100)* %P, i64 0, i32 0
17 %C = getelementptr %T, %T addrspace(100)* %P, i64 0, i32 1
18 %D = getelementptr %T, %T addrspace(100)* %P, i64 0, i32 1, i64 0
19 %E = getelementptr %T, %T addrspace(100)* %P, i64 0, i32 1, i64 5
20 ret void
21 }
22
23 ; test1 checks that >64 bits of index can be considered.
24 ; If BasicAA is truncating the arithmetic, it will conclude
25 ; that %A and %B must alias when in fact they must not.
26
27 ; CHECK: Function: test1
28 ; CHECK-NOT: MustAlias:
29 ; CHECK: NoAlias:
30 ; CHECK-SAME: %A
31 ; CHECK-SAME: %B
32 define void @test1(double addrspace(100)* %P, i128 %i) {
33 ; 1180591620717411303424 is 2**70
34 ; 590295810358705651712 is 2**69
35 %i70 = add i128 %i, 1180591620717411303424
36 %i69 = add i128 %i, 590295810358705651712
37 %A = getelementptr double, double addrspace(100)* %P, i128 %i70
38 %B = getelementptr double, double addrspace(100)* %P, i128 %i69
39 ret void
40 }
41
42 ; test2 checks that >64 bits of index can be considered
43 ; and computes the same address in two ways to ensure that
44 ; they are considered equivalent.
45
46 ; CHECK: Function: test2
47 ; CHECK: MustAlias:
48 ; CHECK-SAME: %A
49 ; CHECK-SAME: %C
50 define void @test2(double addrspace(100)* %P, i128 %i) {
51 ; 1180591620717411303424 is 2**70
52 ; 590295810358705651712 is 2**69
53 %i70 = add i128 %i, 1180591620717411303424
54 %i69 = add i128 %i, 590295810358705651712
55 %j70 = add i128 %i69, 590295810358705651712
56 %A = getelementptr double, double addrspace(100)* %P, i128 %i70
57 %C = getelementptr double, double addrspace(100)* %P, i128 %j70
58 ret void
59 }
0 ; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
1
2 target datalayout = "e-m:o-p:64:64-f64:32:64-f80:128-n8:16:32-S128"
3 target triple = "x86_64-apple-macosx10.6.0"
4
5 ; The load and store address in the loop body could alias so the load
6 ; can't be hoisted above the store and out of the loop.
7
8 declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1)
9
10 define i64 @foo(i64 %x, i64 %z, i64 %n) {
11 entry:
12 %pool = alloca [59 x i64], align 4
13 %tmp = bitcast [59 x i64]* %pool to i8*
14 call void @llvm.memset.p0i8.i64(i8* nonnull %tmp, i8 0, i64 236, i32 4, i1 false)
15 %cmp3 = icmp eq i64 %n, 0
16 br i1 %cmp3, label %for.end, label %for.body.lr.ph
17
18 for.body.lr.ph: ; preds = %entry
19 %add = add i64 %z, %x
20 %and = and i64 %add, 9223372036854775807
21 %sub = add nsw i64 %and, -9223372036844814062
22 %arrayidx = getelementptr inbounds [59 x i64], [59 x i64]* %pool, i64 0, i64 %sub
23 %arrayidx1 = getelementptr inbounds [59 x i64], [59 x i64]* %pool, i64 0, i64 42
24 br label %for.body
25
26 for.body: ; preds = %for.body.lr.ph, %for.body
27 %i.04 = phi i64 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
28 store i64 %i.04, i64* %arrayidx, align 4
29 %tmp1 = load i64, i64* %arrayidx1, align 4
30 %inc = add nuw i64 %i.04, 1
31 %exitcond = icmp ne i64 %inc, %n
32 br i1 %exitcond, label %for.body, label %for.end.loopexit
33
34 for.end.loopexit: ; preds = %for.body
35 %lcssa = phi i64 [ %tmp1, %for.body ]
36 br label %for.end
37
38 for.end: ; preds = %for.end.loopexit, %entry
39 %s = phi i64 [ 0, %entry ], [ %lcssa, %for.end.loopexit ]
40 ; CHECK: ret i64 %s
41 ret i64 %s
42 }
0 ; RUN: opt -S -basicaa -gvn < %s | FileCheck %s
1 ; RUN: opt -S -basicaa -gvn -basicaa-force-at-least-64b=0 < %s | FileCheck %s
12
23 target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
34 target triple = "i386-apple-macosx10.6.0"