1 ; RUN: llc -ppc-gpr-icmps=all -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -mattr=-crbits -disable-ppc-cmp-opt=0 | FileCheck %s
2 ; RUN: llc -ppc-gpr-icmps=all -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -mattr=-crbits -disable-ppc-cmp-opt=0 -ppc-gen-isel=false | FileCheck --check-prefix=CHECK-NO-ISEL %s
3 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
4 target triple = "powerpc64-unknown-linux-gnu"
6 define signext i32 @foo(i32 signext %a, i32 signext %b, i32* nocapture %c) #0 {
8 %sub = sub nsw i32 %a, %b
9 store i32 %sub, i32* %c, align 4
10 %cmp = icmp sgt i32 %a, %b
11 %cond = select i1 %cmp, i32 %a, i32 %b
18 define signext i32 @foo2(i32 signext %a, i32 signext %b, i32* nocapture %c) #0 {
21 store i32 %shl, i32* %c, align 4
22 %cmp = icmp sgt i32 %shl, 0
23 %conv = zext i1 %cmp to i32
30 define i64 @fool(i64 %a, i64 %b, i64* nocapture %c) #0 {
32 %sub = sub nsw i64 %a, %b
33 store i64 %sub, i64* %c, align 8
34 %cmp = icmp sgt i64 %a, %b
35 %cond = select i1 %cmp, i64 %a, i64 %b
39 ; CHECK-NO-ISEL-LABEL: @fool
40 ; CHECK: subf. [[REG:[0-9]+]], 4, 3
41 ; CHECK: isel 3, 3, 4, 1
42 ; CHECK-NO-ISEL: bc 12, 1, [[TRUE:.LBB[0-9]+]]
43 ; CHECK-NO-ISEL: ori 3, 4, 0
44 ; CHECK-NO-ISEL: b [[SUCCESSOR:.LBB[0-9]+]]
46 ; CHECK: std [[REG]], 0(5)
49 define i64 @foolb(i64 %a, i64 %b, i64* nocapture %c) #0 {
51 %sub = sub nsw i64 %a, %b
52 store i64 %sub, i64* %c, align 8
53 %cmp = icmp sle i64 %a, %b
54 %cond = select i1 %cmp, i64 %a, i64 %b
58 ; CHECK-NO-ISEL-LABEL: @foolb
59 ; CHECK: subf. [[REG:[0-9]+]], 4, 3
60 ; CHECK: isel 3, 4, 3, 1
61 ; CHECK-NO-ISEL: bc 12, 1, [[TRUE:.LBB[0-9]+]]
62 ; CHECK-NO-ISEL-NEXT: b .LBB
63 ; CHECK-NO-ISEL addi: 3, 4, 0
64 ; CHECK: std [[REG]], 0(5)
67 define i64 @foolc(i64 %a, i64 %b, i64* nocapture %c) #0 {
69 %sub = sub nsw i64 %b, %a
70 store i64 %sub, i64* %c, align 8
71 %cmp = icmp sgt i64 %a, %b
72 %cond = select i1 %cmp, i64 %a, i64 %b
76 ; CHECK-NO-ISEL-LABEL: @foolc
77 ; CHECK: subf. [[REG:[0-9]+]], 3, 4
78 ; CHECK: isel 3, 3, 4, 0
79 ; CHECK-NO-ISEL: bc 12, 0, [[TRUE:.LBB[0-9]+]]
80 ; CHECK-NO-ISEL: ori 3, 4, 0
81 ; CHECK-NO-ISEL: b [[SUCCESSOR:.LBB[0-9]+]]
82 ; CHECK: std [[REG]], 0(5)
85 define i64 @foold(i64 %a, i64 %b, i64* nocapture %c) #0 {
87 %sub = sub nsw i64 %b, %a
88 store i64 %sub, i64* %c, align 8
89 %cmp = icmp slt i64 %a, %b
90 %cond = select i1 %cmp, i64 %a, i64 %b
94 ; CHECK-NO-ISEL-LABEL: @foold
95 ; CHECK: subf. [[REG:[0-9]+]], 3, 4
96 ; CHECK: isel 3, 3, 4, 1
97 ; CHECK-NO-ISEL: bc 12, 1, [[TRUE:.LBB[0-9]+]]
98 ; CHECK-NO-ISEL: ori 3, 4, 0
99 ; CHECK-NO-ISEL: b [[SUCCESSOR:.LBB[0-9]+]]
100 ; CHECK: std [[REG]], 0(5)
103 define i64 @foold2(i64 %a, i64 %b, i64* nocapture %c) #0 {
105 %sub = sub nsw i64 %a, %b
106 store i64 %sub, i64* %c, align 8
107 %cmp = icmp slt i64 %a, %b
108 %cond = select i1 %cmp, i64 %a, i64 %b
111 ; CHECK-LABEL: @foold2
112 ; CHECK-NO-ISEL-LABEL: @foold2
113 ; CHECK: subf. [[REG:[0-9]+]], 4, 3
114 ; CHECK: isel 3, 3, 4, 0
115 ; CHECK-NO-ISEL: bc 12, 0, [[TRUE:.LBB[0-9]+]]
116 ; CHECK-NO-ISEL: ori 3, 4, 0
117 ; CHECK-NO-ISEL: b [[SUCCESSOR:.LBB[0-9]+]]
118 ; CHECK: std [[REG]], 0(5)
121 define i64 @foo2l(i64 %a, i64 %b, i64* nocapture %c) #0 {
123 %shl = shl i64 %a, %b
124 store i64 %shl, i64* %c, align 8
125 %cmp = icmp sgt i64 %shl, 0
126 %conv1 = zext i1 %cmp to i64
134 define double @food(double %a, double %b, double* nocapture %c) #0 {
136 %sub = fsub double %a, %b
137 store double %sub, double* %c, align 8
138 %cmp = fcmp ogt double %a, %b
139 %cond = select i1 %cmp, double %a, double %b
143 ; CHECK-NOT: fsub. 0, 1, 2
144 ; CHECK: stfd 0, 0(5)
147 define float @foof(float %a, float %b, float* nocapture %c) #0 {
149 %sub = fsub float %a, %b
150 store float %sub, float* %c, align 4
151 %cmp = fcmp ogt float %a, %b
152 %cond = select i1 %cmp, float %a, float %b
156 ; CHECK-NOT: fsubs. 0, 1, 2
157 ; CHECK: stfs 0, 0(5)
160 declare i64 @llvm.ctpop.i64(i64);
162 define signext i64 @fooct(i64 signext %a, i64 signext %b, i64* nocapture %c) #0 {
164 %sub = sub nsw i64 %a, %b
165 %subc = call i64 @llvm.ctpop.i64(i64 %sub)
166 store i64 %subc, i64* %c, align 4
167 %cmp = icmp sgt i64 %subc, 0
168 %cond = select i1 %cmp, i64 %a, i64 %b
172 ; CHECK-NOT: popcntd.