2012-05-29-MulAddRec.ll 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ; RUN: opt < %s -S -indvars -loop-unroll | FileCheck %s
  2. ;
  3. ; loop-unroll fully unrolls the inner loop, creating an interesting
  4. ; chain of multiplication. indvars forces SCEV to run again on the
  5. ; outer loop. While reducing the recurrence at %mul3, unsigned integer overflow
  6. ; causes one of the terms to reach zero. This forces all multiples in
  7. ; the recurrence to be zero, reducing the whole thing to a constant expression.
  8. ;
  9. ; PR12929: cast<Ty>() argument of incompatible type
  10. ; CHECK: @func
  11. ; CHECK: for.cond:
  12. ; CHECK: %inc1 = phi i8 [ 0, %entry ], [ %0, %for.body ]
  13. ; CHECK: br label %for.body
  14. ; CHECK: for.body:
  15. ; CHECK: %inc.9 = add i8 %inc.8, 1
  16. ; CHECK: %0 = add i8 %inc1, 10
  17. ; CHECK: br label %for.cond
  18. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  19. define void @func() noreturn nounwind uwtable ssp {
  20. entry:
  21. br label %for.cond
  22. for.cond.loopexit: ; preds = %for.body
  23. %mul.lcssa = phi i8 [ %mul, %for.body ]
  24. %0 = add i8 %inc1, 10
  25. %indvars.iv.next = add i8 %indvars.iv, 10
  26. br label %for.cond
  27. for.cond: ; preds = %for.cond.loopexit, %entry
  28. %indvars.iv = phi i8 [ %indvars.iv.next, %for.cond.loopexit ], [ 10, %entry ]
  29. %mul3 = phi i8 [ undef, %entry ], [ %mul.lcssa, %for.cond.loopexit ]
  30. %inc1 = phi i8 [ 0, %entry ], [ %0, %for.cond.loopexit ]
  31. br label %for.body
  32. for.body: ; preds = %for.body, %for.cond
  33. %inc26 = phi i8 [ %inc1, %for.cond ], [ %inc, %for.body ]
  34. %mul45 = phi i8 [ %mul3, %for.cond ], [ %mul, %for.body ]
  35. %inc = add i8 %inc26, 1
  36. %mul = mul i8 %inc26, %mul45
  37. %exitcond = icmp ne i8 %inc, %indvars.iv
  38. br i1 %exitcond, label %for.body, label %for.cond.loopexit
  39. }