Chris Lattner | 74e9547 | 2002-05-06 05:43:36 +0000 | [diff] [blame] | 1 | ; This test makes sure that these instructions are properly eliminated. |
| 2 | ; |
| 3 | |
Chris Lattner | f6f95d0 | 2002-08-02 19:27:58 +0000 | [diff] [blame^] | 4 | ; RUN: if as < %s | opt -instcombine | dis | grep and |
Chris Lattner | 74e9547 | 2002-05-06 05:43:36 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 6022ad0 | 2002-05-06 05:51:26 +0000 | [diff] [blame] | 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 | } |
Chris Lattner | 74e9547 | 2002-05-06 05:43:36 +0000 | [diff] [blame] | 40 | |