blob: d348541dc5f61c258018f3fe64e1e2949f4fbe76 [file] [log] [blame]
Hal Finkel4029c3f2013-04-18 22:54:25 +00001; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -disable-ppc-cmp-opt=0 | FileCheck %s
Hal Finkel860c08c2013-04-18 22:15:08 +00002target 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"
3target triple = "powerpc64-unknown-linux-gnu"
4
5define signext i32 @foo(i32 signext %a, i32 signext %b, i32* nocapture %c) #0 {
6entry:
7 %sub = sub nsw i32 %a, %b
8 store i32 %sub, i32* %c, align 4, !tbaa !0
9 %cmp = icmp sgt i32 %a, %b
10 %cond = select i1 %cmp, i32 %a, i32 %b
11 ret i32 %cond
12
13; CHECK: @foo
14; CHECK-NOT: subf.
15}
16
17define signext i32 @foo2(i32 signext %a, i32 signext %b, i32* nocapture %c) #0 {
18entry:
19 %shl = shl i32 %a, %b
20 store i32 %shl, i32* %c, align 4, !tbaa !0
21 %cmp = icmp sgt i32 %shl, 0
22 %conv = zext i1 %cmp to i32
23 ret i32 %conv
24
25; CHECK: @foo2
26; CHECK-NOT: slw.
27}
28
29define i64 @fool(i64 %a, i64 %b, i64* nocapture %c) #0 {
30entry:
31 %sub = sub nsw i64 %a, %b
32 store i64 %sub, i64* %c, align 8, !tbaa !3
33 %cmp = icmp sgt i64 %a, %b
34 %cond = select i1 %cmp, i64 %a, i64 %b
35 ret i64 %cond
36
37; CHECK: @fool
38; CHECK: subf. [[REG:[0-9]+]], 4, 3
39; CHECK: isel 3, 3, 4, 1
40; CHECK: std [[REG]], 0(5)
41}
42
43define i64 @foolb(i64 %a, i64 %b, i64* nocapture %c) #0 {
44entry:
45 %sub = sub nsw i64 %a, %b
46 store i64 %sub, i64* %c, align 8, !tbaa !3
47 %cmp = icmp sle i64 %a, %b
48 %cond = select i1 %cmp, i64 %a, i64 %b
49 ret i64 %cond
50
51; CHECK: @foolb
52; CHECK: subf. [[REG:[0-9]+]], 4, 3
53; CHECK: isel 3, 4, 3, 1
54; CHECK: std [[REG]], 0(5)
55}
56
57define i64 @foo2l(i64 %a, i64 %b, i64* nocapture %c) #0 {
58entry:
59 %shl = shl i64 %a, %b
60 store i64 %shl, i64* %c, align 8, !tbaa !3
61 %cmp = icmp sgt i64 %shl, 0
62 %conv1 = zext i1 %cmp to i64
63 ret i64 %conv1
64
65; CHECK: @foo2l
66; CHECK: sld. 4, 3, 4
67; CHECK: std 4, 0(5)
68}
69
70define double @food(double %a, double %b, double* nocapture %c) #0 {
71entry:
72 %sub = fsub double %a, %b
73 store double %sub, double* %c, align 8, !tbaa !3
74 %cmp = fcmp ogt double %a, %b
75 %cond = select i1 %cmp, double %a, double %b
76 ret double %cond
77
78; CHECK: @food
79; CHECK: fsub. 0, 1, 2
80; CHECK: stfd 0, 0(5)
81}
82
83define float @foof(float %a, float %b, float* nocapture %c) #0 {
84entry:
85 %sub = fsub float %a, %b
86 store float %sub, float* %c, align 4, !tbaa !3
87 %cmp = fcmp ogt float %a, %b
88 %cond = select i1 %cmp, float %a, float %b
89 ret float %cond
90
91; CHECK: @foof
92; CHECK: fsubs. 0, 1, 2
93; CHECK: stfs 0, 0(5)
94}
95
96!0 = metadata !{metadata !"int", metadata !1}
97!1 = metadata !{metadata !"omnipotent char", metadata !2}
98!2 = metadata !{metadata !"Simple C/C++ TBAA"}
99!3 = metadata !{metadata !"long", metadata !1}
100!4 = metadata !{metadata !"any pointer", metadata !1}
101