lftr-extend-const.ll 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ;RUN: opt -S %s -indvars | FileCheck %s
  2. ; Provide legal integer types.
  3. target datalayout = "n8:16:32:64"
  4. ; CHECK-LABEL: @foo(
  5. ; CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16
  6. ; CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512
  7. define void @foo() #0 {
  8. entry:
  9. br label %for.body
  10. for.body: ; preds = %entry, %for.body
  11. %i.01 = phi i16 [ 0, %entry ], [ %inc, %for.body ]
  12. %conv2 = sext i16 %i.01 to i32
  13. call void @bar(i32 %conv2) #1
  14. %inc = add i16 %i.01, 1
  15. %cmp = icmp slt i16 %inc, 512
  16. br i1 %cmp, label %for.body, label %for.end
  17. for.end: ; preds = %for.body
  18. ret void
  19. }
  20. ; Check that post-incrementing the backedge taken count does not overflow.
  21. ; CHECK-LABEL: @postinc(
  22. ; CHECK: icmp eq i32 %indvars.iv, 255
  23. define i32 @postinc() #0 {
  24. entry:
  25. br label %do.body
  26. do.body: ; preds = %do.body, %entry
  27. %first.0 = phi i8 [ 0, %entry ], [ %inc, %do.body ]
  28. %conv = zext i8 %first.0 to i32
  29. call void @bar(i32 %conv) #1
  30. %inc = add i8 %first.0, 1
  31. %cmp = icmp eq i8 %first.0, -1
  32. br i1 %cmp, label %do.end, label %do.body
  33. do.end: ; preds = %do.body
  34. ret i32 0
  35. }
  36. declare void @bar(i32)
  37. attributes #0 = { nounwind uwtable }
  38. attributes #1 = { nounwind }