apint-and1.ll 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ; This test makes sure that and instructions are properly eliminated.
  2. ; This test is for Integer BitWidth <= 64 && BitWidth % 8 != 0.
  3. ; RUN: opt < %s -instcombine -S | not grep "and "
  4. ; END.
  5. define i39 @test0(i39 %A) {
  6. %B = and i39 %A, 0 ; zero result
  7. ret i39 %B
  8. }
  9. define i47 @test1(i47 %A, i47 %B) {
  10. ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
  11. %NotA = xor i47 %A, -1
  12. %NotB = xor i47 %B, -1
  13. %C1 = and i47 %NotA, %NotB
  14. ret i47 %C1
  15. }
  16. define i15 @test2(i15 %x) {
  17. %tmp.2 = and i15 %x, -1 ; noop
  18. ret i15 %tmp.2
  19. }
  20. define i23 @test3(i23 %x) {
  21. %tmp.0 = and i23 %x, 127
  22. %tmp.2 = and i23 %tmp.0, 128
  23. ret i23 %tmp.2
  24. }
  25. define i1 @test4(i37 %x) {
  26. %A = and i37 %x, -2147483648
  27. %B = icmp ne i37 %A, 0
  28. ret i1 %B
  29. }
  30. define i7 @test5(i7 %A, i7* %P) {
  31. %B = or i7 %A, 3
  32. %C = xor i7 %B, 12
  33. store i7 %C, i7* %P
  34. %r = and i7 %C, 3
  35. ret i7 %r
  36. }
  37. define i7 @test6(i7 %A, i7 %B) {
  38. ;; ~(~X & Y) --> (X | ~Y)
  39. %t0 = xor i7 %A, -1
  40. %t1 = and i7 %t0, %B
  41. %r = xor i7 %t1, -1
  42. ret i7 %r
  43. }
  44. define i47 @test7(i47 %A) {
  45. %X = ashr i47 %A, 39 ;; sign extend
  46. %C1 = and i47 %X, 255
  47. ret i47 %C1
  48. }