1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py 2; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s 3 4define void @foo(ptr nocapture %arg, i32 %arg1, i32 %arg2) { 5; CHECK-LABEL: 'foo' 6; CHECK-NEXT: Classifying expressions for: @foo 7; CHECK-NEXT: %tmp4 = zext i32 %arg2 to i64 8; CHECK-NEXT: --> (zext i32 %arg2 to i64) U: [0,4294967296) S: [0,4294967296) 9; CHECK-NEXT: %tmp8 = phi i64 [ %tmp18, %bb7 ], [ 0, %bb3 ] 10; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%bb7> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (zext i32 %arg2 to i64))<nsw> LoopDispositions: { %bb7: Computable } 11; CHECK-NEXT: %tmp9 = shl i64 %tmp8, 33 12; CHECK-NEXT: --> {0,+,8589934592}<nuw><%bb7> U: [0,-17179869183) S: [-9223372036854775808,9223372028264841217) Exits: (-8589934592 + (8589934592 * (zext i32 %arg2 to i64))) LoopDispositions: { %bb7: Computable } 13; CHECK-NEXT: %tmp10 = ashr exact i64 %tmp9, 32 14; CHECK-NEXT: --> (sext i32 {0,+,2}<%bb7> to i64) U: [0,-1) S: [-2147483648,2147483647) Exits: (sext i32 (-2 + (2 * %arg2)) to i64) LoopDispositions: { %bb7: Computable } 15; CHECK-NEXT: %tmp11 = getelementptr inbounds i32, ptr %arg, i64 %tmp10 16; CHECK-NEXT: --> ((4 * (sext i32 {0,+,2}<%bb7> to i64))<nsw> + %arg) U: full-set S: full-set Exits: ((4 * (sext i32 (-2 + (2 * %arg2)) to i64))<nsw> + %arg) LoopDispositions: { %bb7: Computable } 17; CHECK-NEXT: %tmp12 = load i32, ptr %tmp11, align 4 18; CHECK-NEXT: --> %tmp12 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 19; CHECK-NEXT: %tmp13 = sub nsw i32 %tmp12, %arg1 20; CHECK-NEXT: --> ((-1 * %arg1) + %tmp12) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 21; CHECK-NEXT: %tmp14 = or disjoint i64 %tmp10, 1 22; CHECK-NEXT: --> (1 + (sext i32 {0,+,2}<%bb7> to i64))<nuw><nsw> U: [1,0) S: [-2147483647,2147483648) Exits: (1 + (sext i32 (-2 + (2 * %arg2)) to i64))<nuw><nsw> LoopDispositions: { %bb7: Computable } 23; CHECK-NEXT: %tmp15 = getelementptr inbounds i32, ptr %arg, i64 %tmp14 24; CHECK-NEXT: --> (4 + (4 * (sext i32 {0,+,2}<%bb7> to i64))<nsw> + %arg) U: full-set S: full-set Exits: (4 + (4 * (sext i32 (-2 + (2 * %arg2)) to i64))<nsw> + %arg) LoopDispositions: { %bb7: Computable } 25; CHECK-NEXT: %tmp16 = load i32, ptr %tmp15, align 4 26; CHECK-NEXT: --> %tmp16 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 27; CHECK-NEXT: %tmp17 = mul nsw i32 %tmp16, %arg1 28; CHECK-NEXT: --> (%arg1 * %tmp16) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 29; CHECK-NEXT: %tmp18 = add nuw nsw i64 %tmp8, 1 30; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%bb7> U: [1,2147483648) S: [1,2147483648) Exits: (zext i32 %arg2 to i64) LoopDispositions: { %bb7: Computable } 31; CHECK-NEXT: Determining loop execution counts for: @foo 32; CHECK-NEXT: Loop %bb7: backedge-taken count is (-1 + (zext i32 %arg2 to i64))<nsw> 33; CHECK-NEXT: Loop %bb7: constant max backedge-taken count is i64 2147483646 34; CHECK-NEXT: Loop %bb7: symbolic max backedge-taken count is (-1 + (zext i32 %arg2 to i64))<nsw> 35; CHECK-NEXT: Loop %bb7: Trip multiple is 1 36; 37bb: 38 %tmp = icmp sgt i32 %arg2, 0 39 br i1 %tmp, label %bb3, label %bb6 40 41bb3: ; preds = %bb 42 %tmp4 = zext i32 %arg2 to i64 43 br label %bb7 44 45bb5: ; preds = %bb7 46 br label %bb6 47 48bb6: ; preds = %bb5, %bb 49 ret void 50 51bb7: ; preds = %bb7, %bb3 52 %tmp8 = phi i64 [ %tmp18, %bb7 ], [ 0, %bb3 ] 53 %tmp9 = shl i64 %tmp8, 33 54 %tmp10 = ashr exact i64 %tmp9, 32 55 %tmp11 = getelementptr inbounds i32, ptr %arg, i64 %tmp10 56 %tmp12 = load i32, ptr %tmp11, align 4 57 %tmp13 = sub nsw i32 %tmp12, %arg1 58 store i32 %tmp13, ptr %tmp11, align 4 59 %tmp14 = or disjoint i64 %tmp10, 1 60 %tmp15 = getelementptr inbounds i32, ptr %arg, i64 %tmp14 61 %tmp16 = load i32, ptr %tmp15, align 4 62 %tmp17 = mul nsw i32 %tmp16, %arg1 63 store i32 %tmp17, ptr %tmp15, align 4 64 %tmp18 = add nuw nsw i64 %tmp8, 1 65 %tmp19 = icmp eq i64 %tmp18, %tmp4 66 br i1 %tmp19, label %bb5, label %bb7 67} 68 69define void @goo(ptr nocapture %arg3, i32 %arg4, i32 %arg5) { 70; CHECK-LABEL: 'goo' 71; CHECK-NEXT: Classifying expressions for: @goo 72; CHECK-NEXT: %t4 = zext i32 %arg5 to i128 73; CHECK-NEXT: --> (zext i32 %arg5 to i128) U: [0,4294967296) S: [0,4294967296) 74; CHECK-NEXT: %t8 = phi i128 [ %t18, %bb7 ], [ 0, %bb3 ] 75; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%bb7> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (zext i32 %arg5 to i128))<nsw> LoopDispositions: { %bb7: Computable } 76; CHECK-NEXT: %t9 = shl i128 %t8, 100 77; CHECK-NEXT: --> {0,+,1267650600228229401496703205376}<%bb7> U: [0,-1267650600228229401496703205375) S: [-170141183460469231731687303715884105728,170141182192818631503457902219180900353) Exits: (-1267650600228229401496703205376 + (1267650600228229401496703205376 * (zext i32 %arg5 to i128))) LoopDispositions: { %bb7: Computable } 78; CHECK-NEXT: %t10 = ashr exact i128 %t9, 1 79; CHECK-NEXT: --> (sext i127 {0,+,633825300114114700748351602688}<%bb7> to i128) U: [0,-633825300114114700748351602687) S: [-85070591730234615865843651857942052864,85070591096409315751728951109590450177) Exits: (sext i127 (-633825300114114700748351602688 + (633825300114114700748351602688 * (zext i32 %arg5 to i127))) to i128) LoopDispositions: { %bb7: Computable } 80; CHECK-NEXT: %t11 = getelementptr inbounds i32, ptr %arg3, i128 %t10 81; CHECK-NEXT: --> %arg3 U: full-set S: full-set Exits: %arg3 LoopDispositions: { %bb7: Invariant } 82; CHECK-NEXT: %t12 = load i32, ptr %t11, align 4 83; CHECK-NEXT: --> %t12 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 84; CHECK-NEXT: %t13 = sub nsw i32 %t12, %arg4 85; CHECK-NEXT: --> ((-1 * %arg4) + %t12) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 86; CHECK-NEXT: %t14 = or disjoint i128 %t10, 1 87; CHECK-NEXT: --> (1 + (sext i127 {0,+,633825300114114700748351602688}<%bb7> to i128))<nuw><nsw> U: [1,-633825300114114700748351602686) S: [-85070591730234615865843651857942052863,85070591096409315751728951109590450178) Exits: (1 + (sext i127 (-633825300114114700748351602688 + (633825300114114700748351602688 * (zext i32 %arg5 to i127))) to i128))<nuw><nsw> LoopDispositions: { %bb7: Computable } 88; CHECK-NEXT: %t15 = getelementptr inbounds i32, ptr %arg3, i128 %t14 89; CHECK-NEXT: --> (4 + %arg3)<nuw> U: [4,0) S: [4,0) Exits: (4 + %arg3)<nuw> LoopDispositions: { %bb7: Invariant } 90; CHECK-NEXT: %t16 = load i32, ptr %t15, align 4 91; CHECK-NEXT: --> %t16 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 92; CHECK-NEXT: %t17 = mul nsw i32 %t16, %arg4 93; CHECK-NEXT: --> (%arg4 * %t16) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant } 94; CHECK-NEXT: %t18 = add nuw nsw i128 %t8, 1 95; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%bb7> U: [1,2147483648) S: [1,2147483648) Exits: (zext i32 %arg5 to i128) LoopDispositions: { %bb7: Computable } 96; CHECK-NEXT: Determining loop execution counts for: @goo 97; CHECK-NEXT: Loop %bb7: backedge-taken count is (-1 + (zext i32 %arg5 to i128))<nsw> 98; CHECK-NEXT: Loop %bb7: constant max backedge-taken count is i128 2147483646 99; CHECK-NEXT: Loop %bb7: symbolic max backedge-taken count is (-1 + (zext i32 %arg5 to i128))<nsw> 100; CHECK-NEXT: Loop %bb7: Trip multiple is 1 101; 102bb: 103 %t = icmp sgt i32 %arg5, 0 104 br i1 %t, label %bb3, label %bb6 105 106bb3: ; preds = %bb 107 %t4 = zext i32 %arg5 to i128 108 br label %bb7 109 110bb5: ; preds = %bb7 111 br label %bb6 112 113bb6: ; preds = %bb5, %bb 114 ret void 115 116bb7: ; preds = %bb7, %bb3 117 %t8 = phi i128 [ %t18, %bb7 ], [ 0, %bb3 ] 118 %t9 = shl i128 %t8, 100 119 %t10 = ashr exact i128 %t9, 1 120 %t11 = getelementptr inbounds i32, ptr %arg3, i128 %t10 121 %t12 = load i32, ptr %t11, align 4 122 %t13 = sub nsw i32 %t12, %arg4 123 store i32 %t13, ptr %t11, align 4 124 %t14 = or disjoint i128 %t10, 1 125 %t15 = getelementptr inbounds i32, ptr %arg3, i128 %t14 126 %t16 = load i32, ptr %t15, align 4 127 %t17 = mul nsw i32 %t16, %arg4 128 store i32 %t17, ptr %t15, align 4 129 %t18 = add nuw nsw i128 %t8, 1 130 %t19 = icmp eq i128 %t18, %t4 131 br i1 %t19, label %bb5, label %bb7 132} 133