blob: 4625698532bf5bb3d537efc3577efb15074fdfd2 [file] [log] [blame]
Duncan Sands3421d902010-12-21 13:32:22 +00001; RUN: opt < %s -instsimplify -S | FileCheck %s
2
3define 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
13define 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}