From: Justin Lebar Date: Wed, 17 Feb 2016 17:46:52 +0000 (+0000) Subject: [NVPTX] Test that MachineSink won't sink across llvm.cuda.syncthreads. X-Git-Tag: llvmorg-3.9.0-rc1~13922 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b5c7b1c00fc3bf4bdfb7fa7e7429594990c50609;p=platform%2Fupstream%2Fllvm.git [NVPTX] Test that MachineSink won't sink across llvm.cuda.syncthreads. Summary: The syncthreads MI is modeled as mayread/maywrite -- convergence doesn't even come into play here. Nonetheless this property is highly implicit in the tablegen files, so a test seems appropriate. Reviewers: jingyue Subscribers: llvm-commits, jholewinski Differential Revision: http://reviews.llvm.org/D17319 llvm-svn: 261114 --- diff --git a/llvm/test/CodeGen/NVPTX/MachineSink-convergent.ll b/llvm/test/CodeGen/NVPTX/MachineSink-convergent.ll new file mode 100644 index 0000000..c06fe22 --- /dev/null +++ b/llvm/test/CodeGen/NVPTX/MachineSink-convergent.ll @@ -0,0 +1,23 @@ +; RUN: llc < %s | FileCheck %s +target triple = "nvptx64-nvidia-cuda" + +declare void @llvm.cuda.syncthreads() + +; Load a value, then syncthreads. Branch, and use the loaded value only on one +; side of the branch. The load shouldn't be sunk beneath the call, because +; syncthreads is modeled as maystore. +define i32 @f(i32 %x, i32* %ptr, i1 %cond) { +Start: + ; CHECK: ld.u32 + %ptr_val = load i32, i32* %ptr + ; CHECK: bar.sync + call void @llvm.cuda.syncthreads() + 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 +}