1141e845dSRoman Lebedev; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py 29adbb5cbSArthur Eubanks; RUN: opt < %s -S -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s 3141e845dSRoman Lebedev 4141e845dSRoman Lebedev; Reduced from test-suite/MultiSource/Benchmarks/MiBench/office-ispell/correct.c 5141e845dSRoman Lebedev; getelementptr, obviously, takes pointer as it's base, and returns a pointer. 6141e845dSRoman Lebedev; SCEV operands are sorted in hope that it increases folding potential, 7141e845dSRoman Lebedev; and at the same time SCEVAddExpr's type is the type of the last(!) operand. 8141e845dSRoman Lebedev; Which means, in some exceedingly rare cases, pointer operand may happen to 9141e845dSRoman Lebedev; end up not being the last operand, and as a result SCEV for GEP will suddenly 10141e845dSRoman Lebedev; have a non-pointer return type. We should ensure that does not happen. 11141e845dSRoman Lebedev 12141e845dSRoman Lebedevtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 13141e845dSRoman Lebedevtarget triple = "x86_64-unknown-linux-gnu" 14141e845dSRoman Lebedev 15*cc19628eSNikita Popov@c = dso_local local_unnamed_addr global ptr null, align 8 16141e845dSRoman Lebedev@a = dso_local local_unnamed_addr global i32 0, align 4 17141e845dSRoman Lebedev@b = dso_local global [1 x i32] zeroinitializer, align 4 18141e845dSRoman Lebedev 19141e845dSRoman Lebedevdefine i32 @d(i32 %base) { 20141e845dSRoman Lebedev; CHECK-LABEL: 'd' 21141e845dSRoman Lebedev; CHECK-NEXT: Classifying expressions for: @d 22141e845dSRoman Lebedev; CHECK-NEXT: %e = alloca [1 x [1 x i8]], align 1 23141e845dSRoman Lebedev; CHECK-NEXT: --> %e U: full-set S: full-set 24*cc19628eSNikita Popov; CHECK-NEXT: %0 = bitcast ptr %e to ptr 25141e845dSRoman Lebedev; CHECK-NEXT: --> %e U: full-set S: full-set 26141e845dSRoman Lebedev; CHECK-NEXT: %f.0 = phi i32 [ %base, %entry ], [ %inc, %for.cond ] 27141e845dSRoman Lebedev; CHECK-NEXT: --> {%base,+,1}<nsw><%for.cond> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Computable } 28141e845dSRoman Lebedev; CHECK-NEXT: %idxprom = sext i32 %f.0 to i64 29141e845dSRoman Lebedev; CHECK-NEXT: --> {(sext i32 %base to i64),+,1}<nsw><%for.cond> U: [-2147483648,-9223372036854775808) S: [-2147483648,-9223372036854775808) Exits: <<Unknown>> LoopDispositions: { %for.cond: Computable } 30*cc19628eSNikita Popov; CHECK-NEXT: %arrayidx = getelementptr inbounds [1 x [1 x i8]], ptr %e, i64 0, i64 %idxprom 31f3124a46SNikita Popov; CHECK-NEXT: --> {((sext i32 %base to i64) + %e),+,1}<nw><%for.cond> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Computable } 32*cc19628eSNikita Popov; CHECK-NEXT: %1 = load ptr, ptr @c, align 8 33141e845dSRoman Lebedev; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } 34*cc19628eSNikita Popov; CHECK-NEXT: %sub.ptr.lhs.cast = ptrtoint ptr %1 to i64 35*cc19628eSNikita Popov; CHECK-NEXT: --> (ptrtoint ptr %1 to i64) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } 36*cc19628eSNikita Popov; CHECK-NEXT: %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, ptrtoint (ptr @b to i64) 37*cc19628eSNikita Popov; CHECK-NEXT: --> ((-1 * (ptrtoint ptr @b to i64)) + (ptrtoint ptr %1 to i64)) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } 38141e845dSRoman Lebedev; CHECK-NEXT: %sub.ptr.div = sdiv exact i64 %sub.ptr.sub, 4 394a5edea1SPhilip Reames; CHECK-NEXT: --> %sub.ptr.div U: [-2305843009213693952,2305843009213693952) S: [-2305843009213693952,2305843009213693952) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } 40*cc19628eSNikita Popov; CHECK-NEXT: %arrayidx1 = getelementptr inbounds [1 x i8], ptr %arrayidx, i64 0, i64 %sub.ptr.div 41f3124a46SNikita Popov; CHECK-NEXT: --> ({((sext i32 %base to i64) + %e),+,1}<nw><%for.cond> + %sub.ptr.div) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } 42*cc19628eSNikita Popov; CHECK-NEXT: %2 = load i8, ptr %arrayidx1, align 1 43141e845dSRoman Lebedev; CHECK-NEXT: --> %2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } 44141e845dSRoman Lebedev; CHECK-NEXT: %conv = sext i8 %2 to i32 45141e845dSRoman Lebedev; CHECK-NEXT: --> (sext i8 %2 to i32) U: [-128,128) S: [-128,128) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } 46141e845dSRoman Lebedev; CHECK-NEXT: %inc = add nsw i32 %f.0, 1 47141e845dSRoman Lebedev; CHECK-NEXT: --> {(1 + %base),+,1}<nw><%for.cond> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Computable } 48141e845dSRoman Lebedev; CHECK-NEXT: Determining loop execution counts for: @d 49141e845dSRoman Lebedev; CHECK-NEXT: Loop %for.cond: <multiple exits> Unpredictable backedge-taken count. 50211d9411SMax Kazantsev; CHECK-NEXT: Loop %for.cond: Unpredictable constant max backedge-taken count. 51e5fa7eb1SMax Kazantsev; CHECK-NEXT: Loop %for.cond: Unpredictable symbolic max backedge-taken count. 52141e845dSRoman Lebedev; 53141e845dSRoman Lebedeventry: 54141e845dSRoman Lebedev %e = alloca [1 x [1 x i8]], align 1 55*cc19628eSNikita Popov %0 = bitcast ptr %e to ptr 56*cc19628eSNikita Popov call void @llvm.lifetime.start.p0(i64 1, ptr %0) #2 57141e845dSRoman Lebedev br label %for.cond 58141e845dSRoman Lebedev 59141e845dSRoman Lebedevfor.cond: ; preds = %for.cond, %entry 60141e845dSRoman Lebedev %f.0 = phi i32 [ %base, %entry ], [ %inc, %for.cond ] 61141e845dSRoman Lebedev %idxprom = sext i32 %f.0 to i64 62*cc19628eSNikita Popov %arrayidx = getelementptr inbounds [1 x [1 x i8]], ptr %e, i64 0, i64 %idxprom 63*cc19628eSNikita Popov %1 = load ptr, ptr @c, align 8 64*cc19628eSNikita Popov %sub.ptr.lhs.cast = ptrtoint ptr %1 to i64 65*cc19628eSNikita Popov %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, ptrtoint (ptr @b to i64) 66141e845dSRoman Lebedev %sub.ptr.div = sdiv exact i64 %sub.ptr.sub, 4 67*cc19628eSNikita Popov %arrayidx1 = getelementptr inbounds [1 x i8], ptr %arrayidx, i64 0, i64 %sub.ptr.div 68*cc19628eSNikita Popov %2 = load i8, ptr %arrayidx1, align 1 69141e845dSRoman Lebedev %conv = sext i8 %2 to i32 70*cc19628eSNikita Popov store i32 %conv, ptr @a, align 4 71141e845dSRoman Lebedev %inc = add nsw i32 %f.0, 1 72141e845dSRoman Lebedev br label %for.cond 73141e845dSRoman Lebedev} 74141e845dSRoman Lebedev 75*cc19628eSNikita Popovdeclare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) 76