test for a variety of new transformations:
[oota-llvm.git] / test / Transforms / InstCombine / and.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3
4 ; RUN: if as < %s | opt -instcombine | dis | grep and
5 ; RUN: then exit 1
6 ; RUN: else exit 0
7 ; RUN: fi
8
9 implementation
10
11 int %test1(int %A) {
12         %B = and int %A, 0     ; zero result
13         ret int %B
14 }
15
16 int %test2(int %A) {
17         %B = and int %A, -1    ; noop
18         ret int %B
19 }
20
21 bool %test3(bool %A) {
22         %B = and bool %A, false  ; always = false
23         ret bool %B
24 }
25
26 bool %test4(bool %A) {
27         %B = and bool %A, true  ; noop
28         ret bool %B
29 }
30
31 int %test5(int %A) {
32         %B = and int %A, %A
33         ret int %B
34 }
35
36 bool %test6(bool %A) {
37         %B = and bool %A, %A
38         ret bool %B
39 }
40
41 int %test7(int %A) {         ; A & ~A == 0
42         %NotA = xor int %A, -1
43         %B = and int %A, %NotA
44         ret int %B
45 }