Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NVPTX] Use ldg for explicitly invariant loads.
Summary: With this change (plus some changes to prevent !invariant from being clobbered within llvm), clang will be able to model the __ldg CUDA builtin as an invariant load, rather than as a target-specific llvm intrinsic. This will let the optimizer play with these loads -- specifically, we should be able to vectorize them in the load-store vectorizer. Reviewers: tra Subscribers: jholewinski, hfinkel, llvm-commits, chandlerc Differential Revision: https://reviews.llvm.org/D23477 llvm-svn: 281152
- Loading branch information
Justin Lebar
committed
Sep 11, 2016
1 parent
adbf09e
commit 6d6b11a
Showing
2 changed files
with
49 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
; RUN: llc < %s -march=nvptx64 -mcpu=sm_35 | FileCheck %s | ||
|
||
; Check that invariant loads from the global addrspace are lowered to | ||
; ld.global.nc. | ||
|
||
; CHECK-LABEL: @ld_global | ||
define i32 @ld_global(i32 addrspace(1)* %ptr) { | ||
; CHECK: ld.global.nc.{{[a-z]}}32 | ||
%a = load i32, i32 addrspace(1)* %ptr, !invariant.load !0 | ||
ret i32 %a | ||
} | ||
|
||
; CHECK-LABEL: @ld_not_invariant | ||
define i32 @ld_not_invariant(i32 addrspace(1)* %ptr) { | ||
; CHECK: ld.global.{{[a-z]}}32 | ||
%a = load i32, i32 addrspace(1)* %ptr | ||
ret i32 %a | ||
} | ||
|
||
; CHECK-LABEL: @ld_not_global_addrspace | ||
define i32 @ld_not_global_addrspace(i32 addrspace(0)* %ptr) { | ||
; CHECK: ld.{{[a-z]}}32 | ||
%a = load i32, i32 addrspace(0)* %ptr | ||
ret i32 %a | ||
} | ||
|
||
!0 = !{} |