aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/PTX/setp.ll
blob: 5348482e093f008a63121e99772c428ec3606ea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
; RUN: llc < %s -march=ptx | FileCheck %s

define ptx_device i32 @test_setp_eq_u32_rr(i32 %x, i32 %y) {
; CHECK: setp.eq.u32 p0, r1, r2;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp eq i32 %x, %y
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_ne_u32_rr(i32 %x, i32 %y) {
; CHECK: setp.ne.u32 p0, r1, r2;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ne i32 %x, %y
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_lt_u32_rr(i32 %x, i32 %y) {
; CHECK: setp.lt.u32 p0, r1, r2;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ult i32 %x, %y
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_le_u32_rr(i32 %x, i32 %y) {
; CHECK: setp.le.u32 p0, r1, r2;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ule i32 %x, %y
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_gt_u32_rr(i32 %x, i32 %y) {
; CHECK: setp.gt.u32 p0, r1, r2;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ugt i32 %x, %y
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_ge_u32_rr(i32 %x, i32 %y) {
; CHECK: setp.ge.u32 p0, r1, r2;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp uge i32 %x, %y
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_eq_u32_ri(i32 %x) {
; CHECK: setp.eq.u32 p0, r1, 1;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp eq i32 %x, 1
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_ne_u32_ri(i32 %x) {
; CHECK: setp.ne.u32 p0, r1, 1;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ne i32 %x, 1
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_lt_u32_ri(i32 %x) {
; CHECK: setp.eq.u32 p0, r1, 0;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ult i32 %x, 1
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_le_u32_ri(i32 %x) {
; CHECK: setp.lt.u32 p0, r1, 2;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ule i32 %x, 1
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_gt_u32_ri(i32 %x) {
; CHECK: setp.gt.u32 p0, r1, 1;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp ugt i32 %x, 1
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_ge_u32_ri(i32 %x) {
; CHECK: setp.ne.u32 p0, r1, 0;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%p = icmp uge i32 %x, 1
	%z = zext i1 %p to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_4_op_format_1(i32 %x, i32 %y, i32 %u, i32 %v) {
; CHECK: setp.gt.u32 p0, r3, r4;
; CHECK-NEXT: setp.eq.and.u32 p0, r1, r2, p0;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%c = icmp eq i32 %x, %y
	%d = icmp ugt i32 %u, %v
	%e = and i1 %c, %d
	%z = zext i1 %e to i32
	ret i32 %z
}

define ptx_device i32 @test_setp_4_op_format_2(i32 %x, i32 %y, i32 %w) {
; CHECK: cvt.pred.u32 p0, r3;
; CHECK-NEXT: setp.eq.and.u32 p0, r1, r2, !p0;
; CHECK-NEXT: cvt.u32.pred r0, p0;
; CHECK-NEXT: ret;
	%c = trunc i32 %w to i1
	%d = icmp eq i32 %x, %y
	%e = xor i1 %c, 1
	%f = and i1 %d, %e
	%z = zext i1 %f to i32
	ret i32 %z
}