-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NVPTX] Add 'activemask' builtin and intrinsic support (#79768)
Summary: This patch adds support for getting the 'activemask' instruction's value without needing to use inline assembly. See the relevant PTX reference for details. https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-activemask
- Loading branch information
Showing
6 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
; RUN: llc < %s -march=nvptx64 -O2 -mcpu=sm_52 -mattr=+ptx62 | FileCheck %s | ||
; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_52 -mattr=+ptx62 | %ptxas-verify %} | ||
|
||
declare i32 @llvm.nvvm.activemask() | ||
|
||
; CHECK-LABEL: activemask( | ||
; | ||
; CHECK: activemask.b32 %[[REG:.+]]; | ||
; CHECK-NEXT: st.param.b32 [func_retval0+0], %[[REG]]; | ||
; CHECK-NEXT: ret; | ||
define dso_local i32 @activemask() { | ||
entry: | ||
%mask = call i32 @llvm.nvvm.activemask() | ||
ret i32 %mask | ||
} | ||
|
||
; CHECK-LABEL: convergent( | ||
; | ||
; CHECK: activemask.b32 %[[REG:.+]]; | ||
; CHECK: activemask.b32 %[[REG]]; | ||
; CHECK: .param.b32 [func_retval0+0], %[[REG]]; | ||
; CHECK-NEXT: ret; | ||
define dso_local i32 @convergent(i1 %cond) { | ||
entry: | ||
br i1 %cond, label %if.else, label %if.then | ||
|
||
if.then: | ||
%0 = call i32 @llvm.nvvm.activemask() | ||
br label %if.end | ||
|
||
if.else: | ||
%1 = call i32 @llvm.nvvm.activemask() | ||
br label %if.end | ||
|
||
if.end: | ||
%mask = phi i32 [ %0, %if.then ], [ %1, %if.else ] | ||
ret i32 %mask | ||
} |