Duncan Sands | 3421d90 | 2010-12-21 13:32:22 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -instsimplify -S | FileCheck %s |
| 2 | |
| 3 | define i32 @factorize(i32 %x, i32 %y) { |
| 4 | ; CHECK: @factorize |
| 5 | ; (X | 2) & (X | 2) -> X | (1 & 2) -> X |
| 6 | %l = or i32 %x, 1 |
| 7 | %r = or i32 %x, 2 |
| 8 | %z = and i32 %l, %r |
| 9 | ret i32 %z |
| 10 | ; CHECK: ret i32 %x |
| 11 | } |
| 12 | |
| 13 | define i32 @expand(i32 %x) { |
| 14 | ; CHECK: @expand |
| 15 | ; ((X & 1) | 2) & 1 -> ((X & 1) & 1) | (2 & 1) -> (X & 1) | 0 -> X & 1 |
| 16 | %a = and i32 %x, 1 |
| 17 | %b = or i32 %a, 2 |
| 18 | %c = and i32 %b, 1 |
| 19 | ret i32 %c |
| 20 | ; CHECK: ret i32 %a |
| 21 | } |