masks.ll 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ; RUN: opt -S -consthoist < %s | FileCheck %s
  2. target datalayout = "E-m:e-i64:64-n32:64"
  3. target triple = "powerpc64-unknown-linux-gnu"
  4. ; Here the masks are all contiguous, and should not be hoisted.
  5. define i32 @test1() nounwind {
  6. entry:
  7. ; CHECK-LABEL: @test1
  8. ; CHECK-NOT: bitcast i32 65535 to i32
  9. ; CHECK: and i32 undef, 65535
  10. %conv121 = and i32 undef, 65535
  11. br i1 undef, label %if.then152, label %if.end167
  12. if.then152:
  13. ; CHECK: and i32 undef, 65535
  14. %conv153 = and i32 undef, 65535
  15. br i1 undef, label %if.end167, label %end2
  16. if.end167:
  17. ; CHECK: and i32 {{.*}}, 32768
  18. %shl161 = shl nuw nsw i32 %conv121, 15
  19. %0 = load i8, i8* undef, align 1
  20. %conv169 = zext i8 %0 to i32
  21. %shl170 = shl nuw nsw i32 %conv169, 7
  22. %shl161.masked = and i32 %shl161, 32768
  23. %conv174 = or i32 %shl170, %shl161.masked
  24. %cmp178 = icmp ugt i32 %conv174, 32767
  25. br i1 %cmp178, label %end1, label %end2
  26. end1:
  27. unreachable
  28. end2:
  29. unreachable
  30. }
  31. ; Here the masks are not contiguous, and should be hoisted.
  32. define i32 @test2() nounwind {
  33. entry:
  34. ; CHECK-LABEL: @test2
  35. ; CHECK: bitcast i32 65531 to i32
  36. %conv121 = and i32 undef, 65531
  37. br i1 undef, label %if.then152, label %if.end167
  38. if.then152:
  39. %conv153 = and i32 undef, 65531
  40. br i1 undef, label %if.end167, label %end2
  41. if.end167:
  42. ; CHECK: add i32 {{.*}}, -32758
  43. %shl161 = shl nuw nsw i32 %conv121, 15
  44. %0 = load i8, i8* undef, align 1
  45. %conv169 = zext i8 %0 to i32
  46. %shl170 = shl nuw nsw i32 %conv169, 7
  47. %shl161.masked = and i32 %shl161, 32773
  48. %conv174 = or i32 %shl170, %shl161.masked
  49. %cmp178 = icmp ugt i32 %conv174, 32767
  50. br i1 %cmp178, label %end1, label %end2
  51. end1:
  52. unreachable
  53. end2:
  54. unreachable
  55. }