blob: 998e940e8a69be992f304a8ba07ad89faeffe1eb [file] [log] [blame]
Hal Finkel940ab932014-02-28 00:27:01 +00001; RUN: llc -mcpu=pwr7 < %s | FileCheck %s
2target datalayout = "E-m:e-i64:64-n32:64"
3target triple = "powerpc64-unknown-linux-gnu"
4
5; FIXME: For a number of these we load (1, 0) for the isel into two registers,
6; whereas if we reverse the condition, we could use only one register (using ZERO
7; for 0 in the isel).
8
9; Function Attrs: nounwind readnone
10define zeroext i1 @test1(float %v1, float %v2) #0 {
11entry:
12 %cmp = fcmp oge float %v1, %v2
13 %cmp2 = fcmp ole float %v2, 0.000000e+00
14 %and5 = and i1 %cmp, %cmp2
15 ret i1 %and5
16
17; CHECK-LABEL: @test1
18; CHECK-DAG: fcmpu {{[0-9]+}}, 1, 2
19; CHECK-DAG: li [[REG1:[0-9]+]], 1
20; CHECK-DAG: lfs [[REG2:[0-9]+]],
21; CHECK-DAG: li [[REG3:[0-9]+]], 0
22; CHECK-DAG: fcmpu {{[0-9]+}}, 2, [[REG2]]
23; CHECK: crnor
24; CHECK: crnor
25; CHECK: crand [[REG4:[0-9]+]],
26; CHECK: isel 3, [[REG1]], [[REG3]], [[REG4]]
27; CHECK: blr
28}
29
30; Function Attrs: nounwind readnone
31define zeroext i1 @test2(float %v1, float %v2) #0 {
32entry:
33 %cmp = fcmp oge float %v1, %v2
34 %cmp2 = fcmp ole float %v2, 0.000000e+00
35 %xor5 = xor i1 %cmp, %cmp2
36 ret i1 %xor5
37
38; CHECK-LABEL: @test2
39; CHECK-DAG: fcmpu {{[0-9]+}}, 1, 2
40; CHECK-DAG: li [[REG1:[0-9]+]], 1
41; CHECK-DAG: lfs [[REG2:[0-9]+]],
42; CHECK-DAG: li [[REG3:[0-9]+]], 0
43; CHECK-DAG: fcmpu {{[0-9]+}}, 2, [[REG2]]
44; CHECK: crnor
45; CHECK: crnor
46; CHECK: crxor [[REG4:[0-9]+]],
47; CHECK: isel 3, [[REG1]], [[REG3]], [[REG4]]
48; CHECK: blr
49}
50
51; Function Attrs: nounwind readnone
52define zeroext i1 @test3(float %v1, float %v2, i32 signext %x) #0 {
53entry:
54 %cmp = fcmp oge float %v1, %v2
55 %cmp2 = fcmp ole float %v2, 0.000000e+00
56 %cmp4 = icmp ne i32 %x, -2
57 %and7 = and i1 %cmp2, %cmp4
58 %xor8 = xor i1 %cmp, %and7
59 ret i1 %xor8
60
61; CHECK-LABEL: @test3
62; CHECK-DAG: fcmpu {{[0-9]+}}, 1, 2
63; CHECK-DAG: li [[REG1:[0-9]+]], 1
64; CHECK-DAG: lfs [[REG2:[0-9]+]],
65; CHECK-DAG: li [[REG3:[0-9]+]], 0
66; CHECK-DAG: fcmpu {{[0-9]+}}, 2, [[REG2]]
67; CHECK: crnor
68; CHECK: crnor
69; CHECK: crandc
70; CHECK: crxor [[REG4:[0-9]+]],
71; CHECK: isel 3, [[REG1]], [[REG3]], [[REG4]]
72; CHECK: blr
73}
74
75; Function Attrs: nounwind readnone
76define zeroext i1 @test4(i1 zeroext %v1, i1 zeroext %v2, i1 zeroext %v3) #0 {
77entry:
78 %and8 = and i1 %v1, %v2
79 %or9 = or i1 %and8, %v3
80 ret i1 %or9
81
82; CHECK-DAG: @test4
83; CHECK: and [[REG1:[0-9]+]], 3, 4
84; CHECK: or 3, [[REG1]], 5
85; CHECK: blr
86}
87
88; Function Attrs: nounwind readnone
89define zeroext i1 @test5(i1 zeroext %v1, i1 zeroext %v2, i32 signext %v3) #0 {
90entry:
91 %and6 = and i1 %v1, %v2
92 %cmp = icmp ne i32 %v3, -2
93 %or7 = or i1 %and6, %cmp
94 ret i1 %or7
95
96; CHECK-LABEL: @test5
97; CHECK-DAG: and [[REG1:[0-9]+]], 3, 4
98; CHECK-DAG: cmpwi {{[0-9]+}}, 5, -2
99; CHECK: li [[REG3:[0-9]+]], 1
100; CHECK: andi. {{[0-9]+}}, [[REG1]], 1
101; CHECK: li [[REG4:[0-9]+]], 0
102; CHECK: crorc [[REG5:[0-9]+]],
103; CHECK: isel 3, [[REG3]], [[REG4]], [[REG5]]
104; CHECK: blr
105}
106
107; Function Attrs: nounwind readnone
108define zeroext i1 @test6(i1 zeroext %v1, i1 zeroext %v2, i32 signext %v3) #0 {
109entry:
110 %cmp = icmp ne i32 %v3, -2
111 %or6 = or i1 %cmp, %v2
112 %and7 = and i1 %or6, %v1
113 ret i1 %and7
114
115; CHECK-LABEL: @test6
116; CHECK-DAG: andi. {{[0-9]+}}, 3, 1
117; CHECK-DAG: cmpwi {{[0-9]+}}, 5, -2
118; CHECK-DAG: cror [[REG1:[0-9]+]], 1, 1
119; CHECK: andi. {{[0-9]+}}, 4, 1
120; CHECK: li [[REG2:[0-9]+]], 1
121; CHECK: li [[REG3:[0-9]+]], 0
122; CHECK: crorc [[REG4:[0-9]+]], 1,
123; CHECK: crand [[REG5:[0-9]+]], [[REG4]], [[REG1]]
124; CHECK: isel 3, [[REG2]], [[REG3]], [[REG5]]
125; CHECK: blr
126}
127
128; Function Attrs: nounwind readnone
129define signext i32 @test7(i1 zeroext %v2, i32 signext %i1, i32 signext %i2) #0 {
130entry:
131 %cond = select i1 %v2, i32 %i1, i32 %i2
132 ret i32 %cond
133
134; CHECK-LABEL: @test7
135; CHECK: andi. {{[0-9]+}}, 3, 1
136; CHECK: isel [[REG1:[0-9]+]], 4, 5, 1
137; CHECK: extsw 3, [[REG1]]
138; CHECK: blr
139}
140
141; Function Attrs: nounwind readnone
142define float @test8(i1 zeroext %v2, float %v1, float %v3) #0 {
143entry:
144 %cond = select i1 %v2, float %v1, float %v3
145 ret float %cond
146
147; CHECK-LABEL: @test8
148; CHECK: andi. {{[0-9]+}}, 3, 1
149; CHECK: bclr 12, 1, 0
150; CHECK: fmr 1, 2
151; CHECK: blr
152}
153
154; Function Attrs: nounwind readnone
155define signext i32 @test10(i32 signext %v1, i32 signext %v2) #0 {
156entry:
157 %tobool = icmp ne i32 %v1, 0
158 %lnot = icmp eq i32 %v2, 0
159 %and3 = and i1 %tobool, %lnot
160 %and = zext i1 %and3 to i32
161 ret i32 %and
162
163; CHECK-LABEL: @test10
164; CHECK-DAG: cmpwi {{[0-9]+}}, 3, 0
165; CHECK-DAG: cmpwi {{[0-9]+}}, 4, 0
166; CHECK-DAG: li [[REG1:[0-9]+]], 0
167; CHECK-DAG: li [[REG2:[0-9]+]], 1
168; CHECK: crandc [[REG3:[0-9]+]],
169; CHECK: isel 3, [[REG2]], [[REG1]], [[REG3]]
170; CHECK: blr
171}
172
173attributes #0 = { nounwind readnone }
174