ult-sub-to-eq.ll 1.6 KB

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