[X86][AVX512] Added support for AVX512 UNPCK shuffle decode comments.
[oota-llvm.git] / test / CodeGen / X86 / or-lea.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
2
3 ; InstCombine and DAGCombiner transform an 'add' into an 'or'
4 ; if there are no common bits from the incoming operands.
5 ; LEA instruction selection should be able to see through that
6 ; transform and reduce add/shift/or instruction counts.
7
8 define i32 @or_shift1_and1(i32 %x, i32 %y) {
9 ; CHECK-LABEL: or_shift1_and1:
10 ; CHECK:       # BB#0:
11 ; CHECK-NEXT:    andl $1, %esi
12 ; CHECK-NEXT:    leal (%rsi,%rdi,2), %eax
13 ; CHECK-NEXT:    retq
14
15   %shl = shl i32 %x, 1
16   %and = and i32 %y, 1
17   %or = or i32 %and, %shl
18   ret i32 %or
19 }
20
21 define i32 @or_shift1_and1_swapped(i32 %x, i32 %y) {
22 ; CHECK-LABEL: or_shift1_and1_swapped:
23 ; CHECK:       # BB#0:
24 ; CHECK-NEXT:    andl $1, %esi
25 ; CHECK-NEXT:    leal (%rsi,%rdi,2), %eax
26 ; CHECK-NEXT:    retq
27
28   %shl = shl i32 %x, 1
29   %and = and i32 %y, 1
30   %or = or i32 %shl, %and
31   ret i32 %or
32 }
33
34 define i32 @or_shift2_and1(i32 %x, i32 %y) {
35 ; CHECK-LABEL: or_shift2_and1:
36 ; CHECK:       # BB#0:
37 ; CHECK-NEXT:    andl $1, %esi
38 ; CHECK-NEXT:    leal (%rsi,%rdi,4), %eax
39 ; CHECK-NEXT:    retq
40
41   %shl = shl i32 %x, 2
42   %and = and i32 %y, 1
43   %or = or i32 %shl, %and
44   ret i32 %or
45 }
46
47 define i32 @or_shift3_and1(i32 %x, i32 %y) {
48 ; CHECK-LABEL: or_shift3_and1:
49 ; CHECK:       # BB#0:
50 ; CHECK-NEXT:    andl $1, %esi
51 ; CHECK-NEXT:    leal (%rsi,%rdi,8), %eax
52 ; CHECK-NEXT:    retq
53
54   %shl = shl i32 %x, 3
55   %and = and i32 %y, 1
56   %or = or i32 %shl, %and
57   ret i32 %or
58 }
59
60 define i32 @or_shift3_and7(i32 %x, i32 %y) {
61 ; CHECK-LABEL: or_shift3_and7:
62 ; CHECK:       # BB#0:
63 ; CHECK-NEXT:    andl $7, %esi
64 ; CHECK-NEXT:    leal (%rsi,%rdi,8), %eax
65 ; CHECK-NEXT:    retq
66
67   %shl = shl i32 %x, 3
68   %and = and i32 %y, 7
69   %or = or i32 %shl, %and
70   ret i32 %or
71 }
72
73 ; The shift is too big for an LEA.
74
75 define i32 @or_shift4_and1(i32 %x, i32 %y) {
76 ; CHECK-LABEL: or_shift4_and1:
77 ; CHECK:       # BB#0:
78 ; CHECK-NEXT:    shll $4, %edi
79 ; CHECK-NEXT:    andl $1, %esi
80 ; CHECK-NEXT:    leal (%rsi,%rdi), %eax
81 ; CHECK-NEXT:    retq
82
83   %shl = shl i32 %x, 4
84   %and = and i32 %y, 1
85   %or = or i32 %shl, %and
86   ret i32 %or
87 }
88
89 ; The mask is too big for the shift, so the 'or' isn't equivalent to an 'add'.
90
91 define i32 @or_shift3_and8(i32 %x, i32 %y) {
92 ; CHECK-LABEL: or_shift3_and8:
93 ; CHECK:       # BB#0:
94 ; CHECK-NEXT:    leal (,%rdi,8), %eax
95 ; CHECK-NEXT:    andl $8, %esi
96 ; CHECK-NEXT:    orl %esi, %eax
97 ; CHECK-NEXT:    retq
98
99   %shl = shl i32 %x, 3
100   %and = and i32 %y, 8
101   %or = or i32 %shl, %and
102   ret i32 %or
103 }
104
105 ; 64-bit operands should work too.
106
107 define i64 @or_shift1_and1_64(i64 %x, i64 %y) {
108 ; CHECK-LABEL: or_shift1_and1_64:
109 ; CHECK:       # BB#0:
110 ; CHECK-NEXT:    andl $1, %esi
111 ; CHECK-NEXT:    leaq (%rsi,%rdi,2), %rax
112 ; CHECK-NEXT:    retq
113
114   %shl = shl i64 %x, 1
115   %and = and i64 %y, 1
116   %or = or i64 %and, %shl
117   ret i64 %or
118 }
119