1; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s 2; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s 3 4; The initial SCEV for the backedge count is 5; (zext i2 {(trunc i32 (1 + %a1) to i2),+,1}<%b2> to i32). 6; In howFarToZero, this was further converted to an add-rec, the complexity 7; of which defeated the calculation of the backedge taken count. 8; Since such zero-extensions preserve the values being extended, strip 9; them in howFarToZero to simplify the input SCEV. 10 11; Check that the backedge taken count was actually computed: 12; CHECK: Determining loop execution counts for: @f0 13; CHECK-NEXT: Loop %b2: backedge-taken count is (-1 + (-1 * (trunc i32 %a1 to i2))) 14 15target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" 16 17define i32 @f0(i32 %a0, i32 %a1, i32* nocapture %a2) #0 { 18b0: 19 %v0 = and i32 %a1, 3 20 %v1 = icmp eq i32 %v0, 0 21 br i1 %v1, label %b4, label %b1 22 23b1: ; preds = %b0 24 %v2 = shl i32 %a0, 7 25 %v3 = add i32 %v2, -128 26 br label %b2 27 28b2: ; preds = %b2, %b1 29 %v4 = phi i32 [ %a1, %b1 ], [ %v9, %b2 ] 30 %v5 = phi i32* [ %a2, %b1 ], [ %v8, %b2 ] 31 %v6 = getelementptr inbounds i32, i32* %v5, i32 0 32 store i32 %v3, i32* %v6, align 4 33 %v8 = getelementptr inbounds i32, i32* %v5, i32 1 34 %v9 = add nsw i32 %v4, 1 35 %v10 = and i32 %v9, 3 36 %v11 = icmp eq i32 %v10, 0 37 br i1 %v11, label %b3, label %b2 38 39b3: ; preds = %b2 40 br label %b4 41 42b4: ; preds = %b3, %b0 43 ret i32 0 44} 45 46attributes #0 = { norecurse nounwind } 47