preserve-gep-loop-variant.ll 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ; RUN: opt < %s -loop-reduce -S | FileCheck %s
  2. ; CHECK-NOT: {{inttoptr|ptrtoint}}
  3. ; CHECK: scevgep
  4. ; CHECK-NOT: {{inttoptr|ptrtoint}}
  5. target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n32:64"
  6. ; Indvars shouldn't need inttoptr/ptrtoint to expand an address here.
  7. define void @foo(i8* %p) nounwind {
  8. entry:
  9. br i1 true, label %bb.nph, label %for.end
  10. for.cond:
  11. %phitmp = icmp slt i64 %inc, 20
  12. br i1 %phitmp, label %for.body, label %for.cond.for.end_crit_edge
  13. for.cond.for.end_crit_edge:
  14. br label %for.end
  15. bb.nph:
  16. br label %for.body
  17. for.body:
  18. %storemerge1 = phi i64 [ %inc, %for.cond ], [ 0, %bb.nph ]
  19. %call = tail call i64 @bar() nounwind
  20. %call2 = tail call i64 @car() nounwind
  21. %conv = trunc i64 %call2 to i8
  22. %conv3 = sext i8 %conv to i64
  23. %add = add nsw i64 %call, %storemerge1
  24. %add4 = add nsw i64 %add, %conv3
  25. %arrayidx = getelementptr inbounds i8, i8* %p, i64 %add4
  26. store i8 0, i8* %arrayidx
  27. %inc = add nsw i64 %storemerge1, 1
  28. br label %for.cond
  29. for.end:
  30. ret void
  31. }
  32. declare i64 @bar()
  33. declare i64 @car()