blob: 3e85692500e94a09013d19778ab31bf08f7a7767 [file] [log] [blame]
Chris Lattner679da032002-05-06 17:00:47 +00001; This test makes sure that these instructions are properly eliminated.
2;
3
Reid Spencerd0e30dc2006-12-02 04:23:10 +00004; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep xor
Chris Lattner679da032002-05-06 17:00:47 +00005
6implementation
7
Chris Lattnere9e7ab52002-08-20 17:07:02 +00008int %test1(int %A) {
9 %B = xor int %A, -1
10 %C = xor int %B, -1
Chris Lattner679da032002-05-06 17:00:47 +000011 ret int %C
12}
13
Chris Lattnerf75c3332002-08-21 17:11:18 +000014bool %test2(int %A, int %B) {
15 %cond = setle int %A, %B ; Can change into setge
16 %Ret = xor bool %cond, true
17 ret bool %Ret
18}
Chris Lattnerad1e0532002-08-23 18:31:18 +000019
20
21; Test that demorgans law can be instcombined
22int %test3(int %A, int %B) {
23 %a = xor int %A, -1
24 %b = xor int %B, -1
25 %c = and int %a, %b
26 %d = xor int %c, -1
27 ret int %d
28}
Chris Lattnerf7a83852003-03-10 23:13:32 +000029
30; Test that demorgens law can work with constants
31int %test4(int %A, int %B) {
32 %a = xor int %A, -1
33 %c = and int %a, 5 ; 5 = ~c2
34 %d = xor int %c, -1
35 ret int %d
36}
37
38; test the mirror of demorgans law...
39int %test5(int %A, int %B) {
40 %a = xor int %A, -1
41 %b = xor int %B, -1
42 %c = or int %a, %b
43 %d = xor int %c, -1
44 ret int %d
45}