676ec4c9e9a9d06a7cfbb0715c99f6d8d20f5228
[oota-llvm.git] / test / Transforms / InstCombine / apint-or1.ll
1 ; This test makes sure that or instructions are properly eliminated.
2 ; This test is for Integer BitWidth <= 64 && BitWidth % 2 != 0.
3 ;
4
5 ; RUN: opt < %s -instcombine -S | not grep " or "
6
7
8 define i7 @test0(i7 %X) {
9     %Y = or i7 %X, 0
10     ret i7 %Y
11 }
12
13 define i17 @test1(i17 %X) {
14     %Y = or i17 %X, -1
15     ret i17 %Y
16
17
18 define i23 @test2(i23 %A) {
19     ;; A | ~A == -1
20     %NotA = xor i23 -1, %A
21     %B = or i23 %A, %NotA
22     ret i23 %B
23 }
24
25 define i39 @test3(i39 %V, i39 %M) {
26     ;; If we have: ((V + N) & C1) | (V & C2)
27     ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
28     ;; replace with V+N.
29     %C1 = xor i39 274877906943, -1 ;; C2 = 274877906943
30     %N = and i39 %M, 274877906944
31     %A = add i39 %V, %N
32     %B = and i39 %A, %C1
33     %D = and i39 %V, 274877906943
34     %R = or i39 %B, %D
35     ret i39 %R
36 }
37
38 define i43 @demorgan(i43 %A, i43 %B) {
39     ;; (~A | ~B) == (~(A & B)) - De Morgan's Law
40     %NotA = xor i43 %A, -1
41     %NotB = xor i43 %B, -1
42     %C1 = or i43 %NotA, %NotB
43     ret i43 %C1
44 }
45