1
1
; RUN: llc < %s -mtriple=nvptx64 | FileCheck %s
2
2
3
- define i64 @test1 (i64 %x , i32 %y ) {
3
+ define i64 @test_or (i64 %x , i32 %y ) {
4
4
;
5
5
; srl (or (x, shl(zext(y),c1)),c1) -> or(srl(x,c1), zext(y))
6
6
; c1 <= leadingzeros(zext(y))
7
7
;
8
- ; CHECK-LABEL: test1
9
- ; CHECK: ld.param.u64 %[[X:rd[0-9]+]], [test1_param_0 ];
10
- ; CHECK: ld.param.u32 %[[Y:rd[0-9]+]], [test1_param_1 ];
8
+ ; CHECK-LABEL: test_or
9
+ ; CHECK: ld.param.u64 %[[X:rd[0-9]+]], [test_or_param_0 ];
10
+ ; CHECK: ld.param.u32 %[[Y:rd[0-9]+]], [test_or_param_1 ];
11
11
; CHECK: shr.u64 %[[SHR:rd[0-9]+]], %[[X]], 5;
12
- ; CHECK: or.b64 %[[OR :rd[0-9]+]], %[[SHR]], %[[Y]];
13
- ; CHECK: st.param.b64 [func_retval0], %[[OR ]];
12
+ ; CHECK: or.b64 %[[LOP :rd[0-9]+]], %[[SHR]], %[[Y]];
13
+ ; CHECK: st.param.b64 [func_retval0], %[[LOP ]];
14
14
;
15
15
%ext = zext i32 %y to i64
16
16
%shl = shl i64 %ext , 5
@@ -19,6 +19,63 @@ define i64 @test1(i64 %x, i32 %y) {
19
19
ret i64 %srl
20
20
}
21
21
22
+ define i64 @test_xor (i64 %x , i32 %y ) {
23
+ ;
24
+ ; srl (xor (x, shl(zext(y),c1)),c1) -> xor(srl(x,c1), zext(y))
25
+ ; c1 <= leadingzeros(zext(y))
26
+ ;
27
+ ; CHECK-LABEL: test_xor
28
+ ; CHECK: ld.param.u64 %[[X:rd[0-9]+]], [test_xor_param_0];
29
+ ; CHECK: ld.param.u32 %[[Y:rd[0-9]+]], [test_xor_param_1];
30
+ ; CHECK: shr.u64 %[[SHR:rd[0-9]+]], %[[X]], 5;
31
+ ; CHECK: xor.b64 %[[LOP:rd[0-9]+]], %[[SHR]], %[[Y]];
32
+ ; CHECK: st.param.b64 [func_retval0], %[[LOP]];
33
+ ;
34
+ %ext = zext i32 %y to i64
35
+ %shl = shl i64 %ext , 5
36
+ %or = xor i64 %x , %shl
37
+ %srl = lshr i64 %or , 5
38
+ ret i64 %srl
39
+ }
40
+
41
+ define i64 @test_and (i64 %x , i32 %y ) {
42
+ ;
43
+ ; srl (and (x, shl(zext(y),c1)),c1) -> and(srl(x,c1), zext(y))
44
+ ; c1 <= leadingzeros(zext(y))
45
+ ;
46
+ ; CHECK-LABEL: test_and
47
+ ; CHECK: ld.param.u64 %[[X:rd[0-9]+]], [test_and_param_0];
48
+ ; CHECK: ld.param.u32 %[[Y:rd[0-9]+]], [test_and_param_1];
49
+ ; CHECK: shr.u64 %[[SHR:rd[0-9]+]], %[[X]], 5;
50
+ ; CHECK: and.b64 %[[LOP:rd[0-9]+]], %[[SHR]], %[[Y]];
51
+ ; CHECK: st.param.b64 [func_retval0], %[[LOP]];
52
+ ;
53
+ %ext = zext i32 %y to i64
54
+ %shl = shl i64 %ext , 5
55
+ %or = and i64 %x , %shl
56
+ %srl = lshr i64 %or , 5
57
+ ret i64 %srl
58
+ }
59
+
60
+ define <2 x i64 > @test_or_vec (<2 x i64 > %x , <2 x i32 > %y ) {
61
+ ;
62
+ ; srl (or (x, shl(zext(y),c1)),c1) -> or(srl(x,c1), zext(y))
63
+ ; c1 <= leadingzeros(zext(y))
64
+ ;
65
+ ; CHECK-LABEL: test_or
66
+ ; CHECK: ld.param.u64 %[[X:rd[0-9]+]], [test_or_param_0];
67
+ ; CHECK: ld.param.u32 %[[Y:rd[0-9]+]], [test_or_param_1];
68
+ ; CHECK: shr.u64 %[[SHR:rd[0-9]+]], %[[X]], 5;
69
+ ; CHECK: or.b64 %[[LOP:rd[0-9]+]], %[[SHR]], %[[Y]];
70
+ ; CHECK: st.param.b64 [func_retval0], %[[LOP]];
71
+ ;
72
+ %ext = zext <2 x i32 > %y to <2 x i64 >
73
+ %shl = shl <2 x i64 > %ext , splat(i64 5 )
74
+ %or = or <2 x i64 > %x , %shl
75
+ %srl = lshr <2 x i64 > %or , splat(i64 5 )
76
+ ret <2 x i64 > %srl
77
+ }
78
+
22
79
define i64 @test2 (i64 %x , i32 %y ) {
23
80
;
24
81
; srl (or (x, shl(zext(y),c1)),c1) -> or(srl(x,c1), zext(y))
0 commit comments