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