1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -S -unroll-threshold=20 -loop-unroll -unroll-allow-partial -unroll-runtime -unroll-allow-remainder -unroll-dynamic-cost-savings-discount=0 | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; The Loop TripCount is 9. However unroll factors 3 or 9 exceed given threshold. 4*9880d681SAndroid Build Coastguard Worker; The test checks that we choose a smaller, power-of-two, unroll count and do not give up on unrolling. 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; CHECK: for.body: 7*9880d681SAndroid Build Coastguard Worker; CHECK: store 8*9880d681SAndroid Build Coastguard Worker; CHECK: for.body.1: 9*9880d681SAndroid Build Coastguard Worker; CHECK: store 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Workerdefine void @foo(i32* nocapture %a, i32* nocapture readonly %b) nounwind uwtable { 12*9880d681SAndroid Build Coastguard Workerentry: 13*9880d681SAndroid Build Coastguard Worker br label %for.body 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Workerfor.body: ; preds = %for.body, %entry 16*9880d681SAndroid Build Coastguard Worker %indvars.iv = phi i64 [ 1, %entry ], [ %indvars.iv.next, %for.body ] 17*9880d681SAndroid Build Coastguard Worker %arrayidx = getelementptr inbounds i32, i32* %b, i64 %indvars.iv 18*9880d681SAndroid Build Coastguard Worker %ld = load i32, i32* %arrayidx, align 4 19*9880d681SAndroid Build Coastguard Worker %idxprom1 = sext i32 %ld to i64 20*9880d681SAndroid Build Coastguard Worker %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %idxprom1 21*9880d681SAndroid Build Coastguard Worker %st = trunc i64 %indvars.iv to i32 22*9880d681SAndroid Build Coastguard Worker store i32 %st, i32* %arrayidx2, align 4 23*9880d681SAndroid Build Coastguard Worker %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 24*9880d681SAndroid Build Coastguard Worker %exitcond = icmp eq i64 %indvars.iv.next, 10 25*9880d681SAndroid Build Coastguard Worker br i1 %exitcond, label %for.end, label %for.body 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %for.body 28*9880d681SAndroid Build Coastguard Worker ret void 29*9880d681SAndroid Build Coastguard Worker} 30