blob: 7dd3d554b651e92dca1232bd9e61f6b8411245d1 [file] [log] [blame]
Chris Lattner74e95472002-05-06 05:43:36 +00001; This test makes sure that these instructions are properly eliminated.
2;
3
Chris Lattnerf6f95d02002-08-02 19:27:58 +00004; RUN: if as < %s | opt -instcombine | dis | grep and
Chris Lattner74e95472002-05-06 05:43:36 +00005; RUN: then exit 1
6; RUN: else exit 0
7; RUN: fi
8
9implementation
10
Chris Lattner2deaf772003-02-18 18:06:44 +000011int %test1(int %A) {
Chris Lattner74e95472002-05-06 05:43:36 +000012 %B = and int %A, 0 ; zero result
13 ret int %B
14}
15
Chris Lattner2deaf772003-02-18 18:06:44 +000016int %test2(int %A) {
Chris Lattner74e95472002-05-06 05:43:36 +000017 %B = and int %A, -1 ; noop
18 ret int %B
19}
20
Chris Lattner2deaf772003-02-18 18:06:44 +000021bool %test3(bool %A) {
Chris Lattner74e95472002-05-06 05:43:36 +000022 %B = and bool %A, false ; always = false
23 ret bool %B
24}
25
Chris Lattner2deaf772003-02-18 18:06:44 +000026bool %test4(bool %A) {
Chris Lattner74e95472002-05-06 05:43:36 +000027 %B = and bool %A, true ; noop
28 ret bool %B
29}
30
Chris Lattner2deaf772003-02-18 18:06:44 +000031int %test5(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000032 %B = and int %A, %A
33 ret int %B
34}
35
Chris Lattner2deaf772003-02-18 18:06:44 +000036bool %test6(bool %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000037 %B = and bool %A, %A
38 ret bool %B
39}
Chris Lattner74e95472002-05-06 05:43:36 +000040
Chris Lattnerc5fccf32003-02-18 19:28:47 +000041int %test7(int %A) { ; A & ~A == 0
42 %NotA = xor int %A, -1
43 %B = and int %A, %NotA
44 ret int %B
45}