Chris Lattner | 679da03 | 2002-05-06 17:00:47 +0000 | [diff] [blame] | 1 | ; This test makes sure that these instructions are properly eliminated. |
| 2 | ; |
| 3 | |
Chris Lattner | f9b9af0 | 2002-08-14 17:37:04 +0000 | [diff] [blame] | 4 | ; RUN: if as < %s | opt -instcombine -die | dis | grep xor |
Chris Lattner | 679da03 | 2002-05-06 17:00:47 +0000 | [diff] [blame] | 5 | ; RUN: then exit 1 |
| 6 | ; RUN: else exit 0 |
| 7 | ; RUN: fi |
| 8 | |
| 9 | implementation |
| 10 | |
Chris Lattner | e9e7ab5 | 2002-08-20 17:07:02 +0000 | [diff] [blame] | 11 | int %test1(int %A) { |
| 12 | %B = xor int %A, -1 |
| 13 | %C = xor int %B, -1 |
Chris Lattner | 679da03 | 2002-05-06 17:00:47 +0000 | [diff] [blame] | 14 | ret int %C |
| 15 | } |
| 16 | |
Chris Lattner | f75c333 | 2002-08-21 17:11:18 +0000 | [diff] [blame] | 17 | bool %test2(int %A, int %B) { |
| 18 | %cond = setle int %A, %B ; Can change into setge |
| 19 | %Ret = xor bool %cond, true |
| 20 | ret bool %Ret |
| 21 | } |
Chris Lattner | ad1e053 | 2002-08-23 18:31:18 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | ; Test that demorgans law can be instcombined |
| 25 | int %test3(int %A, int %B) { |
| 26 | %a = xor int %A, -1 |
| 27 | %b = xor int %B, -1 |
| 28 | %c = and int %a, %b |
| 29 | %d = xor int %c, -1 |
| 30 | ret int %d |
| 31 | } |
Chris Lattner | f7a8385 | 2003-03-10 23:13:32 +0000 | [diff] [blame^] | 32 | |
| 33 | ; Test that demorgens law can work with constants |
| 34 | int %test4(int %A, int %B) { |
| 35 | %a = xor int %A, -1 |
| 36 | %c = and int %a, 5 ; 5 = ~c2 |
| 37 | %d = xor int %c, -1 |
| 38 | ret int %d |
| 39 | } |
| 40 | |
| 41 | ; test the mirror of demorgans law... |
| 42 | int %test5(int %A, int %B) { |
| 43 | %a = xor int %A, -1 |
| 44 | %b = xor int %B, -1 |
| 45 | %c = or int %a, %b |
| 46 | %d = xor int %c, -1 |
| 47 | ret int %d |
| 48 | } |