pr18165.ll 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ; RUN: opt < %s -loop-reduce -S | FileCheck %s
  2. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  3. target triple = "x86_64-apple-macosx10.9.0"
  4. ; LSR shouldn't reuse IV if the resultant offset is not valid for the operand type.
  5. ; CHECK-NOT: trunc i32 %.ph to i8
  6. %struct.anon = type { i32, i32, i32 }
  7. @c = global i32 1, align 4
  8. @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
  9. @b = common global i32 0, align 4
  10. @a = common global %struct.anon zeroinitializer, align 4
  11. @e = common global %struct.anon zeroinitializer, align 4
  12. @d = common global i32 0, align 4
  13. @f = common global i32 0, align 4
  14. @g = common global i32 0, align 4
  15. @h = common global i32 0, align 4
  16. ; Function Attrs: nounwind optsize ssp uwtable
  17. define i32 @main() #0 {
  18. entry:
  19. %0 = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @a, i64 0, i32 0), align 4, !tbaa !1
  20. %tobool7.i = icmp eq i32 %0, 0
  21. %.promoted.i = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @a, i64 0, i32 2), align 4, !tbaa !6
  22. %f.promoted.i = load i32, i32* @f, align 4, !tbaa !7
  23. br label %for.body6.i.outer
  24. for.body6.i.outer: ; preds = %entry, %lor.end.i
  25. %.ph = phi i32 [ %add.i, %lor.end.i ], [ 0, %entry ]
  26. %or1512.i.ph = phi i32 [ %or15.i, %lor.end.i ], [ %f.promoted.i, %entry ]
  27. %or1410.i.ph = phi i32 [ %or14.i, %lor.end.i ], [ %.promoted.i, %entry ]
  28. %p.addr.16.i.ph = phi i8 [ %inc10.i, %lor.end.i ], [ -128, %entry ]
  29. br i1 %tobool7.i, label %if.end9.i, label %lbl.loopexit.i
  30. lbl.loopexit.i: ; preds = %for.body6.i.outer, %lbl.loopexit.i
  31. br label %lbl.loopexit.i
  32. if.end9.i: ; preds = %for.body6.i.outer
  33. %inc10.i = add i8 %p.addr.16.i.ph, 1
  34. %tobool12.i = icmp eq i8 %p.addr.16.i.ph, 0
  35. br i1 %tobool12.i, label %lor.rhs.i, label %lor.end.i
  36. lor.rhs.i: ; preds = %if.end9.i
  37. %1 = load i32, i32* @b, align 4, !tbaa !7
  38. %dec.i = add nsw i32 %1, -1
  39. store i32 %dec.i, i32* @b, align 4, !tbaa !7
  40. %tobool13.i = icmp ne i32 %1, 0
  41. br label %lor.end.i
  42. lor.end.i: ; preds = %lor.rhs.i, %if.end9.i
  43. %2 = phi i1 [ true, %if.end9.i ], [ %tobool13.i, %lor.rhs.i ]
  44. %lor.ext.i = zext i1 %2 to i32
  45. %or14.i = or i32 %lor.ext.i, %or1410.i.ph
  46. %or15.i = or i32 %or14.i, %or1512.i.ph
  47. %add.i = add nsw i32 %.ph, 2
  48. %cmp.i = icmp slt i32 %add.i, 21
  49. br i1 %cmp.i, label %for.body6.i.outer, label %fn1.exit
  50. fn1.exit: ; preds = %lor.end.i
  51. store i32 0, i32* @g, align 4, !tbaa !7
  52. store i32 %or14.i, i32* getelementptr inbounds (%struct.anon, %struct.anon* @a, i64 0, i32 2), align 4, !tbaa !6
  53. store i32 %or15.i, i32* @f, align 4, !tbaa !7
  54. store i32 %add.i, i32* getelementptr inbounds (%struct.anon, %struct.anon* @e, i64 0, i32 1), align 4, !tbaa !8
  55. store i32 0, i32* @h, align 4, !tbaa !7
  56. %3 = load i32, i32* @b, align 4, !tbaa !7
  57. %call1 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3) #2
  58. ret i32 0
  59. }
  60. ; Function Attrs: nounwind optsize
  61. declare i32 @printf(i8* nocapture readonly, ...) #1
  62. attributes #0 = { nounwind optsize ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
  63. attributes #1 = { nounwind optsize "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
  64. attributes #2 = { nounwind optsize }
  65. !llvm.ident = !{!0}
  66. !0 = !{!"clang version 3.5 "}
  67. !1 = !{!2, !3, i64 0}
  68. !2 = !{!"", !3, i64 0, !3, i64 4, !3, i64 8}
  69. !3 = !{!"int", !4, i64 0}
  70. !4 = !{!"omnipotent char", !5, i64 0}
  71. !5 = !{!"Simple C/C++ TBAA"}
  72. !6 = !{!2, !3, i64 8}
  73. !7 = !{!3, !3, i64 0}
  74. !8 = !{!2, !3, i64 4}