1 ; RUN: opt -S -indvars < %s | FileCheck %s 2 3 ; Provide legal integer types. 4 target datalayout = "n8:16:32:64" 5 6 7 define void @test1(float* nocapture %autoc, float* nocapture %data, float %d, i32 %data_len, i32 %sample) nounwind { 8 entry: 9 %sub = sub i32 %data_len, %sample 10 %cmp4 = icmp eq i32 %data_len, %sample 11 br i1 %cmp4, label %for.end, label %for.body 12 13 for.body: ; preds = %entry, %for.body 14 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] 15 %0 = trunc i64 %indvars.iv to i32 16 %add = add i32 %0, %sample 17 %idxprom = zext i32 %add to i64 18 %arrayidx = getelementptr inbounds float, float* %data, i64 %idxprom 19 %1 = load float, float* %arrayidx, align 4 20 %mul = fmul float %1, %d 21 %arrayidx2 = getelementptr inbounds float, float* %autoc, i64 %indvars.iv 22 %2 = load float, float* %arrayidx2, align 4 23 %add3 = fadd float %2, %mul 24 store float %add3, float* %arrayidx2, align 4 25 %indvars.iv.next = add i64 %indvars.iv, 1 26 %3 = trunc i64 %indvars.iv.next to i32 27 %cmp = icmp ult i32 %3, %sub 28 br i1 %cmp, label %for.body, label %for.end 29 30 for.end: ; preds = %for.body, %entry 31 ret void 32 33 ; CHECK-LABEL: @test1( 34 35 ; First check that we move the sub into the preheader, it doesn't have to be 36 ; executed if %cmp4 == false 37 ; CHECK: for.body.preheader: 38 ; CHECK: sub i32 %data_len, %sample 39 ; CHECK: br label %for.body 40 41 ; Second, check that we turn the IV test into an eq. 42 ; CHECK: %lftr.wideiv = trunc i64 %indvars.iv.next to i32 43 ; CHECK: %exitcond = icmp ne i32 %lftr.wideiv, %0 44 ; CHECK: br i1 %exitcond, label %for.body, label %for.end.loopexit 45 } 46 47