afe076caea92e331183543f97aea6b3e7c92a2c3
[oota-llvm.git] / test / Transforms / Reassociate / inverses.ll
1 ; RUN: opt < %s -reassociate -die -S | FileCheck %s
2
3 define i32 @test1(i32 %a, i32 %b) {
4         %tmp.2 = and i32 %b, %a
5         %tmp.4 = xor i32 %a, -1
6         ; (A&B)&~A == 0
7         %tmp.5 = and i32 %tmp.2, %tmp.4
8         ret i32 %tmp.5
9 ; CHECK-LABEL: @test1(
10 ; CHECK: ret i32 0
11 }
12
13 define i32 @test2(i32 %a, i32 %b) {
14         %tmp.1 = and i32 %a, 1234
15         %tmp.2 = and i32 %b, %tmp.1
16         %tmp.4 = xor i32 %a, -1
17         ; A&~A == 0
18         %tmp.5 = and i32 %tmp.2, %tmp.4
19         ret i32 %tmp.5
20 ; CHECK-LABEL: @test2(
21 ; CHECK: ret i32 0
22 }
23
24 define i32 @test3(i32 %b, i32 %a) {
25         %tmp.1 = add i32 %a, 1234
26         %tmp.2 = add i32 %b, %tmp.1
27         %tmp.4 = sub i32 0, %a
28         ; (b+(a+1234))+-a -> b+1234
29         %tmp.5 = add i32 %tmp.2, %tmp.4
30         ret i32 %tmp.5
31 ; CHECK-LABEL: @test3(
32 ; CHECK: %tmp.5 = add i32 %b, 1234
33 ; CHECK: ret i32 %tmp.5
34 }