ctpop-multiple-users-crash.ll 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. ; RUN: opt -loop-idiom -S < %s | FileCheck %s
  2. target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
  3. target triple = "arm64-apple-ios8.0.0"
  4. ; When we replace the precondition with a ctpop, we need to ensure
  5. ; that only the first branch reads the ctpop. The store prior
  6. ; to that should continue to read from the original compare.
  7. ; CHECK: %tobool.5 = icmp ne i32 %num, 0
  8. ; CHECK: store i1 %tobool.5, i1* %ptr
  9. define internal fastcc i32 @num_bits_set(i32 %num, i1* %ptr) #1 {
  10. entry:
  11. %tobool.5 = icmp ne i32 %num, 0
  12. store i1 %tobool.5, i1* %ptr
  13. br i1 %tobool.5, label %for.body.lr.ph, label %for.end
  14. for.body.lr.ph: ; preds = %entry
  15. br label %for.body
  16. for.body: ; preds = %for.body.lr.ph, %for.body
  17. %count.07 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
  18. %num.addr.06 = phi i32 [ %num, %for.body.lr.ph ], [ %and, %for.body ]
  19. %sub = add i32 %num.addr.06, -1
  20. %and = and i32 %sub, %num.addr.06
  21. %inc = add nsw i32 %count.07, 1
  22. %tobool = icmp ne i32 %and, 0
  23. br i1 %tobool, label %for.body, label %for.end
  24. for.end: ; preds = %for.cond.for.end_crit_edge, %entry
  25. %count.0.lcssa = phi i32 [ %inc, %for.body ], [ 0, %entry ]
  26. ret i32 %count.0.lcssa
  27. }