1 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
2 ; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 | %ptxas-verify %}
6 define i32 @bfe0(i32 %a) {
7 ; CHECK: bfe.u32 %r{{[0-9]+}}, %r{{[0-9]+}}, 4, 4
10 %val0 = ashr i32 %a, 4
11 %val1 = and i32 %val0, 15
16 define i32 @bfe1(i32 %a) {
17 ; CHECK: bfe.u32 %r{{[0-9]+}}, %r{{[0-9]+}}, 3, 3
20 %val0 = ashr i32 %a, 3
21 %val1 = and i32 %val0, 7
26 define i32 @bfe2(i32 %a) {
27 ; CHECK: bfe.u32 %r{{[0-9]+}}, %r{{[0-9]+}}, 5, 3
30 %val0 = ashr i32 %a, 5
31 %val1 = and i32 %val0, 7
35 ; CHECK-LABEL: no_bfe_on_32bit_overflow
36 define i32 @no_bfe_on_32bit_overflow(i32 %a) {
37 ; CHECK-NOT: bfe.u32 %r{{[0-9]+}}, %r{{[0-9]+}}, 31, 4
38 %val0 = ashr i32 %a, 31
39 %val1 = and i32 %val0, 15
43 ; CHECK-LABEL: no_bfe_on_32bit_overflow_shr_and_pair
44 define i32 @no_bfe_on_32bit_overflow_shr_and_pair(i32 %a) {
45 ; CHECK: shr.s32 %r{{[0-9]+}}, %r{{[0-9]+}}, 31
46 ; CHECK: and.b32 %r{{[0-9]+}}, %r{{[0-9]+}}, 15
47 %val0 = ashr i32 %a, 31
48 %val1 = and i32 %val0, 15
52 ; CHECK-LABEL: no_bfe_on_64bit_overflow
53 define i64 @no_bfe_on_64bit_overflow(i64 %a) {
54 ; CHECK-NOT: bfe.u64 %rd{{[0-9]+}}, %rd{{[0-9]+}}, 63, 3
55 %val0 = ashr i64 %a, 63
56 %val1 = and i64 %val0, 7
60 ; CHECK-LABEL: no_bfe_on_64bit_overflow_shr_and_pair
61 define i64 @no_bfe_on_64bit_overflow_shr_and_pair(i64 %a) {
62 ; CHECK: shr.s64 %rd{{[0-9]+}}, %rd{{[0-9]+}}, 63
63 ; CHECK: and.b64 %rd{{[0-9]+}}, %rd{{[0-9]+}}, 7
64 %val0 = ashr i64 %a, 63
65 %val1 = and i64 %val0, 7