xref: /llvm-project/llvm/test/CodeGen/NVPTX/activemask.ll (revision b279f6b098d3849f7f1c1f539b108307d5f8ae2d)
1; RUN: llc < %s -mtriple=nvptx64 -O2 -mcpu=sm_52 -mattr=+ptx62 | FileCheck %s
2; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64 -mcpu=sm_52 -mattr=+ptx62 | %ptxas-verify %}
3
4declare i32 @llvm.nvvm.activemask()
5
6; CHECK-LABEL: activemask(
7;
8;      CHECK: activemask.b32  %[[REG:.+]];
9; CHECK-NEXT: st.param.b32    [func_retval0], %[[REG]];
10; CHECK-NEXT: ret;
11define dso_local i32 @activemask() {
12entry:
13  %mask = call i32 @llvm.nvvm.activemask()
14  ret i32 %mask
15}
16
17; CHECK-LABEL: convergent(
18;
19;      CHECK: activemask.b32  %[[REG:.+]];
20;      CHECK: activemask.b32  %[[REG]];
21;      CHECK: .param.b32    [func_retval0], %[[REG]];
22; CHECK-NEXT: ret;
23define dso_local i32 @convergent(i1 %cond) {
24entry:
25  br i1 %cond, label %if.else, label %if.then
26
27if.then:
28  %0 = call i32 @llvm.nvvm.activemask()
29  br label %if.end
30
31if.else:
32  %1 = call i32 @llvm.nvvm.activemask()
33  br label %if.end
34
35if.end:
36  %mask = phi i32 [ %0, %if.then ], [ %1, %if.else ]
37  ret i32 %mask
38}
39