exit_value_test2.ll 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ; PR23538
  2. ; RUN: opt < %s -indvars -loop-deletion -S | FileCheck %s
  3. ; Check IndVarSimplify should not replace exit value because or else
  4. ; udiv will be introduced by expand and the cost will be high.
  5. ;
  6. ; CHECK-LABEL: @_Z3fooPKcjj(
  7. ; CHECK-NOT: udiv
  8. declare void @_Z3mixRjj(i32* dereferenceable(4), i32)
  9. declare void @llvm.lifetime.start(i64, i8* nocapture)
  10. declare void @llvm.lifetime.end(i64, i8* nocapture)
  11. define i32 @_Z3fooPKcjj(i8* nocapture readonly %s, i32 %len, i32 %c) {
  12. entry:
  13. %a = alloca i32, align 4
  14. %tmp = bitcast i32* %a to i8*
  15. call void @llvm.lifetime.start(i64 4, i8* %tmp)
  16. store i32 -1640531527, i32* %a, align 4
  17. %cmp8 = icmp ugt i32 %len, 11
  18. br i1 %cmp8, label %while.body.lr.ph, label %while.end
  19. while.body.lr.ph: ; preds = %entry
  20. br label %while.body
  21. while.body: ; preds = %while.body, %while.body.lr.ph
  22. %keylen.010 = phi i32 [ %len, %while.body.lr.ph ], [ %sub, %while.body ]
  23. %s.addr.09 = phi i8* [ %s, %while.body.lr.ph ], [ %add.ptr, %while.body ]
  24. %tmp1 = bitcast i8* %s.addr.09 to i32*
  25. %tmp2 = load i32, i32* %tmp1, align 4
  26. %shl.i = shl i32 %tmp2, 1
  27. %and.i = and i32 %shl.i, 16843008
  28. %tmp3 = load i32, i32* %a, align 4
  29. %sub.i = add i32 %tmp3, %tmp2
  30. %add = sub i32 %sub.i, %and.i
  31. store i32 %add, i32* %a, align 4
  32. %add.ptr = getelementptr inbounds i8, i8* %s.addr.09, i64 12
  33. %sub = add i32 %keylen.010, -12
  34. %cmp = icmp ugt i32 %sub, 11
  35. br i1 %cmp, label %while.body, label %while.cond.while.end_crit_edge
  36. while.cond.while.end_crit_edge: ; preds = %while.body
  37. %sub.lcssa = phi i32 [ %sub, %while.body ]
  38. br label %while.end
  39. while.end: ; preds = %while.cond.while.end_crit_edge, %entry
  40. %keylen.0.lcssa = phi i32 [ %sub.lcssa, %while.cond.while.end_crit_edge ], [ %len, %entry ]
  41. call void @_Z3mixRjj(i32* dereferenceable(4) %a, i32 %keylen.0.lcssa)
  42. %tmp4 = load i32, i32* %a, align 4
  43. call void @llvm.lifetime.end(i64 4, i8* %tmp)
  44. ret i32 %tmp4
  45. }