quadradic-exit-value.ll 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ; RUN: opt < %s -analyze -iv-users | FileCheck %s
  2. ; Provide legal integer types.
  3. target datalayout = "n8:16:32:64"
  4. ; The value of %r is dependent on a polynomial iteration expression.
  5. ;
  6. ; CHECK-LABEL: IV Users for loop %foo.loop
  7. ; CHECK: {1,+,3,+,2}<%foo.loop>
  8. define i64 @foo(i64 %n) {
  9. entry:
  10. br label %foo.loop
  11. foo.loop:
  12. %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %foo.loop ]
  13. %indvar.next = add i64 %indvar, 1
  14. %c = icmp eq i64 %indvar.next, %n
  15. br i1 %c, label %exit, label %foo.loop
  16. exit:
  17. %r = mul i64 %indvar.next, %indvar.next
  18. ret i64 %r
  19. }
  20. ; PR15470: LSR miscompile. The test2 function should return '1'.
  21. ;
  22. ; SCEV does not know how to denormalize chained recurrences, so make
  23. ; sure they aren't marked as post-inc users.
  24. ;
  25. ; CHECK-LABEL: IV Users for loop %test2.loop
  26. ; CHECK: %sext.us = {0,+,(16777216 + (-16777216 * %sub.us)),+,33554432}<%test2.loop> in %f = ashr i32 %sext.us, 24
  27. define i32 @test2() {
  28. entry:
  29. br label %test2.loop
  30. test2.loop:
  31. %inc1115.us = phi i32 [ 0, %entry ], [ %inc11.us, %test2.loop ]
  32. %inc11.us = add nsw i32 %inc1115.us, 1
  33. %cmp.us = icmp slt i32 %inc11.us, 2
  34. br i1 %cmp.us, label %test2.loop, label %for.end
  35. for.end:
  36. %tobool.us = icmp eq i32 %inc1115.us, 0
  37. %sub.us = select i1 %tobool.us, i32 0, i32 0
  38. %mul.us = shl i32 %inc1115.us, 24
  39. %sub.cond.us = sub nsw i32 %inc1115.us, %sub.us
  40. %sext.us = mul i32 %mul.us, %sub.cond.us
  41. %f = ashr i32 %sext.us, 24
  42. br label %exit
  43. exit:
  44. ret i32 %f
  45. }