|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py |
| 2 | +; RUN: opt < %s -scalar-evolution -analyze | FileCheck %s |
| 3 | + |
| 4 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 5 | +target triple = "x86_64-unknown-linux-gnu" |
| 6 | + |
| 7 | +define dso_local void @_Z4loopi(i32 %width) local_unnamed_addr #0 { |
| 8 | +; CHECK-LABEL: '_Z4loopi' |
| 9 | +; CHECK-NEXT: Classifying expressions for: @_Z4loopi |
| 10 | +; CHECK-NEXT: %storage = alloca [2 x i32], align 4 |
| 11 | +; CHECK-NEXT: --> %storage U: [0,-3) S: [-9223372036854775808,9223372036854775805) |
| 12 | +; CHECK-NEXT: %0 = bitcast [2 x i32]* %storage to i8* |
| 13 | +; CHECK-NEXT: --> %storage U: [0,-3) S: [-9223372036854775808,9223372036854775805) |
| 14 | +; CHECK-NEXT: %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] |
| 15 | +; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.cond> U: [0,-2147483648) S: [0,-2147483648) Exits: %width LoopDispositions: { %for.cond: Computable } |
| 16 | +; CHECK-NEXT: %rem = srem i32 %i.0, 2 |
| 17 | +; CHECK-NEXT: --> %rem U: [0,2) S: [-2,2) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } |
| 18 | +; CHECK-NEXT: %idxprom = sext i32 %rem to i64 |
| 19 | +; CHECK-NEXT: --> (sext i32 %rem to i64) U: [0,2) S: [-2,2) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } |
| 20 | +; CHECK-NEXT: %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %storage, i64 0, i64 %idxprom |
| 21 | +; CHECK-NEXT: --> ((4 * (sext i32 %rem to i64))<nuw><nsw> + %storage)<nsw> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } |
| 22 | +; CHECK-NEXT: %1 = load i32, i32* %arrayidx, align 4 |
| 23 | +; CHECK-NEXT: --> %1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } |
| 24 | +; CHECK-NEXT: %call = call i32 @_Z3adji(i32 %1) |
| 25 | +; CHECK-NEXT: --> %call U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } |
| 26 | +; CHECK-NEXT: %2 = load i32, i32* %arrayidx, align 4 |
| 27 | +; CHECK-NEXT: --> %2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } |
| 28 | +; CHECK-NEXT: %add = add nsw i32 %2, %call |
| 29 | +; CHECK-NEXT: --> (%2 + %call) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant } |
| 30 | +; CHECK-NEXT: %inc = add nsw i32 %i.0, 1 |
| 31 | +; CHECK-NEXT: --> {1,+,1}<nuw><%for.cond> U: [1,0) S: [1,0) Exits: (1 + %width) LoopDispositions: { %for.cond: Computable } |
| 32 | +; CHECK-NEXT: Determining loop execution counts for: @_Z4loopi |
| 33 | +; CHECK-NEXT: Loop %for.cond: backedge-taken count is %width |
| 34 | +; CHECK-NEXT: Loop %for.cond: max backedge-taken count is -1 |
| 35 | +; CHECK-NEXT: Loop %for.cond: Predicated backedge-taken count is %width |
| 36 | +; CHECK-NEXT: Predicates: |
| 37 | +; CHECK: Loop %for.cond: Trip multiple is 1 |
| 38 | +; |
| 39 | +entry: |
| 40 | + %storage = alloca [2 x i32], align 4 |
| 41 | + %0 = bitcast [2 x i32]* %storage to i8* |
| 42 | + call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #4 |
| 43 | + call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 8, i1 false) |
| 44 | + br label %for.cond |
| 45 | + |
| 46 | +for.cond: |
| 47 | + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] |
| 48 | + %cmp = icmp ne i32 %i.0, %width |
| 49 | + br i1 %cmp, label %for.body, label %for.cond.cleanup |
| 50 | + |
| 51 | +for.cond.cleanup: |
| 52 | + call void @llvm.lifetime.end.p0i8(i64 8, i8* %0) #4 |
| 53 | + ret void |
| 54 | + |
| 55 | +for.body: |
| 56 | + %rem = srem i32 %i.0, 2 |
| 57 | + %idxprom = sext i32 %rem to i64 |
| 58 | + %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %storage, i64 0, i64 %idxprom |
| 59 | + %1 = load i32, i32* %arrayidx, align 4 |
| 60 | + %call = call i32 @_Z3adji(i32 %1) |
| 61 | + %2 = load i32, i32* %arrayidx, align 4 |
| 62 | + %add = add nsw i32 %2, %call |
| 63 | + store i32 %add, i32* %arrayidx, align 4 |
| 64 | + %inc = add nsw i32 %i.0, 1 |
| 65 | + br label %for.cond |
| 66 | +} |
| 67 | + |
| 68 | +declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 |
| 69 | + |
| 70 | +declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #2 |
| 71 | + |
| 72 | +declare dso_local i32 @_Z3adji(i32) local_unnamed_addr #3 |
| 73 | + |
| 74 | +declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 |
0 commit comments