PR6627.ll 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ; RUN: opt -O3 -S < %s | FileCheck %s
  2. ; XFAIL: *
  3. declare i32 @doo(...)
  4. ; PR6627 - This whole nasty sequence should be flattened down to a single
  5. ; 32-bit comparison.
  6. define void @test2(i8* %arrayidx) nounwind ssp {
  7. entry:
  8. %xx = bitcast i8* %arrayidx to i32*
  9. %x1 = load i32, i32* %xx, align 4
  10. %tmp = trunc i32 %x1 to i8
  11. %conv = zext i8 %tmp to i32
  12. %cmp = icmp eq i32 %conv, 127
  13. br i1 %cmp, label %land.lhs.true, label %if.end
  14. land.lhs.true: ; preds = %entry
  15. %arrayidx4 = getelementptr inbounds i8, i8* %arrayidx, i64 1
  16. %tmp5 = load i8, i8* %arrayidx4, align 1
  17. %conv6 = zext i8 %tmp5 to i32
  18. %cmp7 = icmp eq i32 %conv6, 69
  19. br i1 %cmp7, label %land.lhs.true9, label %if.end
  20. land.lhs.true9: ; preds = %land.lhs.true
  21. %arrayidx12 = getelementptr inbounds i8, i8* %arrayidx, i64 2
  22. %tmp13 = load i8, i8* %arrayidx12, align 1
  23. %conv14 = zext i8 %tmp13 to i32
  24. %cmp15 = icmp eq i32 %conv14, 76
  25. br i1 %cmp15, label %land.lhs.true17, label %if.end
  26. land.lhs.true17: ; preds = %land.lhs.true9
  27. %arrayidx20 = getelementptr inbounds i8, i8* %arrayidx, i64 3
  28. %tmp21 = load i8, i8* %arrayidx20, align 1
  29. %conv22 = zext i8 %tmp21 to i32
  30. %cmp23 = icmp eq i32 %conv22, 70
  31. br i1 %cmp23, label %if.then, label %if.end
  32. if.then: ; preds = %land.lhs.true17
  33. %call25 = call i32 (...) @doo()
  34. br label %if.end
  35. if.end:
  36. ret void
  37. ; CHECK-LABEL: @test2(
  38. ; CHECK: %x1 = load i32, i32* %xx, align 4
  39. ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
  40. ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
  41. }
  42. ; PR6627 - This should all be flattened down to one compare. This is the same
  43. ; as test2, except that the initial load is done as an i8 instead of i32, thus
  44. ; requiring widening.
  45. define void @test2a(i8* %arrayidx) nounwind ssp {
  46. entry:
  47. %x1 = load i8, i8* %arrayidx, align 4
  48. %conv = zext i8 %x1 to i32
  49. %cmp = icmp eq i32 %conv, 127
  50. br i1 %cmp, label %land.lhs.true, label %if.end
  51. land.lhs.true: ; preds = %entry
  52. %arrayidx4 = getelementptr inbounds i8, i8* %arrayidx, i64 1
  53. %tmp5 = load i8, i8* %arrayidx4, align 1
  54. %conv6 = zext i8 %tmp5 to i32
  55. %cmp7 = icmp eq i32 %conv6, 69
  56. br i1 %cmp7, label %land.lhs.true9, label %if.end
  57. land.lhs.true9: ; preds = %land.lhs.true
  58. %arrayidx12 = getelementptr inbounds i8, i8* %arrayidx, i64 2
  59. %tmp13 = load i8, i8* %arrayidx12, align 1
  60. %conv14 = zext i8 %tmp13 to i32
  61. %cmp15 = icmp eq i32 %conv14, 76
  62. br i1 %cmp15, label %land.lhs.true17, label %if.end
  63. land.lhs.true17: ; preds = %land.lhs.true9
  64. %arrayidx20 = getelementptr inbounds i8, i8* %arrayidx, i64 3
  65. %tmp21 = load i8, i8* %arrayidx20, align 1
  66. %conv22 = zext i8 %tmp21 to i32
  67. %cmp23 = icmp eq i32 %conv22, 70
  68. br i1 %cmp23, label %if.then, label %if.end
  69. if.then: ; preds = %land.lhs.true17
  70. %call25 = call i32 (...) @doo()
  71. br label %if.end
  72. if.end:
  73. ret void
  74. ; CHECK-LABEL: @test2a(
  75. ; CHECK: %x1 = load i32, i32* {{.*}}, align 4
  76. ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
  77. ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end
  78. }