blob: b0e9fa48a4874a7445e49a974b41458179c0d2cf [file] [log] [blame]
Chris Lattner6022ad02002-05-06 05:51:26 +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 set
Chris Lattner6022ad02002-05-06 05:51:26 +00005; RUN: then exit 1
6; RUN: else exit 0
7; RUN: fi
8
Chris Lattnerce59a3d2002-05-09 19:52:36 +00009%X = uninitialized global int
Chris Lattner6022ad02002-05-06 05:51:26 +000010
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000011bool %test1(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000012 %B = seteq int %A, %A
Chris Lattnerce59a3d2002-05-09 19:52:36 +000013 %C = seteq int* %X, null ; Never true
14 %D = and bool %B, %C
15 ret bool %D
Chris Lattner6022ad02002-05-06 05:51:26 +000016}
17
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000018bool %test2(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000019 %B = setne int %A, %A
Chris Lattnerce59a3d2002-05-09 19:52:36 +000020 %C = setne int* %X, null ; Never false
21 %D = or bool %B, %C
22 ret bool %D
Chris Lattner6022ad02002-05-06 05:51:26 +000023}
24
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000025bool %test3(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000026 %B = setlt int %A, %A
27 ret bool %B
28}
29
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000030bool %test4(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000031 %B = setgt int %A, %A
32 ret bool %B
33}
34
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000035bool %test5(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000036 %B = setle int %A, %A
37 ret bool %B
38}
39
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000040bool %test6(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000041 %B = setge int %A, %A
42 ret bool %B
43}
Chris Lattnerff61e352002-08-03 20:24:58 +000044
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000045bool %test7(uint %A) {
Chris Lattnerff61e352002-08-03 20:24:58 +000046 %B = setge uint %A, 0 ; true
47 ret bool %B
48}
49
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000050bool %test8(uint %A) {
Chris Lattnerff61e352002-08-03 20:24:58 +000051 %B = setlt uint %A, 0 ; false
52 ret bool %B
53}
Chris Lattnerb86ab652002-08-09 23:34:18 +000054
55;; test operations on boolean values these should all be eliminated$a
56bool %test9(bool %A) {
57 %B = setlt bool %A, false ; false
58 ret bool %B
59}
60bool %test10(bool %A) {
61 %B = setgt bool %A, true ; false
62 ret bool %B
63}
64bool %test11(bool %A) {
65 %B = setle bool %A, true ; true
66 ret bool %B
67}
68bool %test12(bool %A) {
69 %B = setge bool %A, false ; true
70 ret bool %B
71}
72bool %test13(bool %A, bool %B) {
73 %C = setge bool %A, %B ; A | ~B
74 ret bool %C
75}
76bool %test14(bool %A, bool %B) {
77 %C = seteq bool %A, %B ; ~(A ^ B)
78 ret bool %C
79}
80
Chris Lattneref337482003-06-01 03:34:53 +000081; These instructions can be turned into cast-to-bool
82bool %test15(sbyte %A, short %A, int %A, long %A) {
83 %B1 = setne sbyte %A, 0
84 %B2 = setne short %A, 0
85 %B3 = setne int %A, 0
86 %B4 = setne long %A, 0
87 %C1 = or bool %B1, %B2
88 %C2 = or bool %B3, %B4
89 %D = or bool %C1, %C2
90 ret bool %D
91}