1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -S -indvars -loop-unroll | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; 3*9880d681SAndroid Build Coastguard Worker; loop-unroll fully unrolls the inner loop, creating an interesting 4*9880d681SAndroid Build Coastguard Worker; chain of multiplication. indvars forces SCEV to run again on the 5*9880d681SAndroid Build Coastguard Worker; outer loop. While reducing the recurrence at %mul3, unsigned integer overflow 6*9880d681SAndroid Build Coastguard Worker; causes one of the terms to reach zero. This forces all multiples in 7*9880d681SAndroid Build Coastguard Worker; the recurrence to be zero, reducing the whole thing to a constant expression. 8*9880d681SAndroid Build Coastguard Worker; 9*9880d681SAndroid Build Coastguard Worker; PR12929: cast<Ty>() argument of incompatible type 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Worker; CHECK: @func 12*9880d681SAndroid Build Coastguard Worker; CHECK: for.cond: 13*9880d681SAndroid Build Coastguard Worker; CHECK: %inc1 = phi i8 [ 0, %entry ], [ %0, %for.body ] 14*9880d681SAndroid Build Coastguard Worker; CHECK: br label %for.body 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker; CHECK: for.body: 17*9880d681SAndroid Build Coastguard Worker; CHECK: %inc.9 = add i8 %inc.8, 1 18*9880d681SAndroid Build Coastguard Worker; CHECK: %0 = add i8 %inc1, 10 19*9880d681SAndroid Build Coastguard Worker; CHECK: br label %for.cond 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-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" 22*9880d681SAndroid Build Coastguard Workerdefine void @func() noreturn nounwind uwtable ssp { 23*9880d681SAndroid Build Coastguard Workerentry: 24*9880d681SAndroid Build Coastguard Worker br label %for.cond 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Workerfor.cond.loopexit: ; preds = %for.body 27*9880d681SAndroid Build Coastguard Worker %mul.lcssa = phi i8 [ %mul, %for.body ] 28*9880d681SAndroid Build Coastguard Worker %0 = add i8 %inc1, 10 29*9880d681SAndroid Build Coastguard Worker %indvars.iv.next = add i8 %indvars.iv, 10 30*9880d681SAndroid Build Coastguard Worker br label %for.cond 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Workerfor.cond: ; preds = %for.cond.loopexit, %entry 33*9880d681SAndroid Build Coastguard Worker %indvars.iv = phi i8 [ %indvars.iv.next, %for.cond.loopexit ], [ 10, %entry ] 34*9880d681SAndroid Build Coastguard Worker %mul3 = phi i8 [ undef, %entry ], [ %mul.lcssa, %for.cond.loopexit ] 35*9880d681SAndroid Build Coastguard Worker %inc1 = phi i8 [ 0, %entry ], [ %0, %for.cond.loopexit ] 36*9880d681SAndroid Build Coastguard Worker br label %for.body 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Workerfor.body: ; preds = %for.body, %for.cond 39*9880d681SAndroid Build Coastguard Worker %inc26 = phi i8 [ %inc1, %for.cond ], [ %inc, %for.body ] 40*9880d681SAndroid Build Coastguard Worker %mul45 = phi i8 [ %mul3, %for.cond ], [ %mul, %for.body ] 41*9880d681SAndroid Build Coastguard Worker %inc = add i8 %inc26, 1 42*9880d681SAndroid Build Coastguard Worker %mul = mul i8 %inc26, %mul45 43*9880d681SAndroid Build Coastguard Worker %exitcond = icmp ne i8 %inc, %indvars.iv 44*9880d681SAndroid Build Coastguard Worker br i1 %exitcond, label %for.body, label %for.cond.loopexit 45*9880d681SAndroid Build Coastguard Worker} 46