1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define i32 @factorize(i32 %x, i32 %y) {
4 ; CHECK-LABEL: @factorize(
5 ; (X | 1) & (X | 2) -> X | (1 & 2) -> X
13 define i32 @factorize2(i32 %x) {
14 ; CHECK-LABEL: @factorize2(
23 define i32 @factorize3(i32 %x, i32 %a, i32 %b) {
24 ; CHECK-LABEL: @factorize3(
25 ; (X | (A|B)) & (X | B) -> X | ((A|B) & B) -> X | B
31 ; CHECK: %z = or i32 %b, %x
35 define i32 @factorize4(i32 %x, i32 %y) {
36 ; CHECK-LABEL: @factorize4(
37 ; ((Y << 1) * X) - (X * Y) -> (X * (Y * 2 - Y)) -> (X * Y)
43 ; CHECK: %s = mul i32 %y, %x
47 define i32 @factorize5(i32 %x, i32 %y) {
48 ; CHECK-LABEL: @factorize5(
49 ; ((Y * 2) * X) - (X * Y) -> (X * Y)
55 ; CHECK: %s = mul i32 %y, %x
59 define i32 @expand(i32 %x) {
60 ; CHECK-LABEL: @expand(
61 ; ((X & 1) | 2) & 1 -> ((X & 1) & 1) | (2 & 1) -> (X & 1) | 0 -> X & 1
66 ; CHECK: %a = and i32 %x, 1