apint-and2.ll 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ; This test makes sure that and instructions are properly eliminated.
  2. ; This test is for Integer BitWidth > 64 && BitWidth <= 1024.
  3. ; RUN: opt < %s -instcombine -S | not grep "and "
  4. ; END.
  5. define i999 @test0(i999 %A) {
  6. %B = and i999 %A, 0 ; zero result
  7. ret i999 %B
  8. }
  9. define i477 @test1(i477 %A, i477 %B) {
  10. ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
  11. %NotA = xor i477 %A, -1
  12. %NotB = xor i477 %B, -1
  13. %C1 = and i477 %NotA, %NotB
  14. ret i477 %C1
  15. }
  16. define i129 @tst(i129 %A, i129 %B) {
  17. ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
  18. %NotA = xor i129 %A, -1
  19. %NotB = xor i129 %B, -1
  20. %C1 = and i129 %NotA, %NotB
  21. ret i129 %C1
  22. }
  23. define i65 @test(i65 %A, i65 %B) {
  24. ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
  25. %NotA = xor i65 %A, -1
  26. %NotB = xor i65 -1, %B
  27. %C1 = and i65 %NotA, %NotB
  28. ret i65 %C1
  29. }
  30. define i66 @tes(i66 %A, i66 %B) {
  31. ;; (~A & ~B) == (~(A | B)) - De Morgan's Law
  32. %NotA = xor i66 %A, -1
  33. %NotB = xor i66 %B, -1
  34. %C1 = and i66 %NotA, %NotB
  35. ret i66 %C1
  36. }
  37. define i1005 @test2(i1005 %x) {
  38. %tmp.2 = and i1005 %x, -1 ; noop
  39. ret i1005 %tmp.2
  40. }
  41. define i123 @test3(i123 %x) {
  42. %tmp.0 = and i123 %x, 127
  43. %tmp.2 = and i123 %tmp.0, 128
  44. ret i123 %tmp.2
  45. }
  46. define i1 @test4(i737 %x) {
  47. %A = and i737 %x, -2147483648
  48. %B = icmp ne i737 %A, 0
  49. ret i1 %B
  50. }
  51. define i117 @test5(i117 %A, i117* %P) {
  52. %B = or i117 %A, 3
  53. %C = xor i117 %B, 12
  54. store i117 %C, i117* %P
  55. %r = and i117 %C, 3
  56. ret i117 %r
  57. }
  58. define i117 @test6(i117 %A, i117 %B) {
  59. ;; ~(~X & Y) --> (X | ~Y)
  60. %t0 = xor i117 %A, -1
  61. %t1 = and i117 %t0, %B
  62. %r = xor i117 %t1, -1
  63. ret i117 %r
  64. }
  65. define i1024 @test7(i1024 %A) {
  66. %X = ashr i1024 %A, 1016 ;; sign extend
  67. %C1 = and i1024 %X, 255
  68. ret i1024 %C1
  69. }