llvm/test/CodeGen/NVPTX/MachineSink-call.ll
Justin Lebar 8c96a189d1 [NVPTX] Annotate call machine instructions as calls.
Summary:
Otherwise we'll try to do unsafe optimizations on these MIs, such as
sinking loads below calls.

(I suspect that this is not the only bug in the NVPTX instruction
tablegen files; I need to comb through them.)

Reviewers: jholewinski, tra

Subscribers: jingyue, jhen, llvm-commits

Differential Revision: http://reviews.llvm.org/D17315

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261113 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-17 17:46:50 +00:00

24 lines
611 B
LLVM

; RUN: llc < %s | FileCheck %s
target triple = "nvptx64-nvidia-cuda"
declare void @foo()
; Load a value, then call a function. Branch, and use the loaded value only on
; one side of the branch. The load shouldn't be sunk beneath the call, because
; the call may modify memory.
define i32 @f(i32 %x, i32* %ptr, i1 %cond) {
Start:
; CHECK: ld.u32
%ptr_val = load i32, i32* %ptr
; CHECK: call.uni
call void @foo()
br i1 %cond, label %L1, label %L2
L1:
%ptr_val2 = add i32 %ptr_val, 100
br label %L2
L2:
%v4 = phi i32 [ %x, %Start ], [ %ptr_val2, %L1 ]
%v5 = add i32 %v4, 1000
ret i32 %v5
}