[PATCH] D32730: LV: Don't insert runtime ptr checks on divergent targets

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 18:52:46 PDT 2017


arsenm created this revision.
Herald added subscribers: nhaehnle, wdng, mzolotukhin.

https://reviews.llvm.org/D32730

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Transforms/LoopVectorize/AMDGPU/divergent-runtime-check.ll


Index: test/Transforms/LoopVectorize/AMDGPU/divergent-runtime-check.ll
===================================================================
--- /dev/null
+++ test/Transforms/LoopVectorize/AMDGPU/divergent-runtime-check.ll
@@ -0,0 +1,26 @@
+; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -loop-vectorize -simplifycfg < %s | FileCheck -check-prefixes=GCN,GFX9 %s
+
+; GCN-LABEL: @runtime_check_divergent_target(
+; GCN-NOT: load <2 x half>
+; GCN-NOT: store <2 x half>
+define amdgpu_kernel void @runtime_check_divergent_target(half addrspace(1)* nocapture %a, half addrspace(1)* nocapture %b) #0 {
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %entry, %for.body
+  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
+  %arrayidx = getelementptr inbounds half, half addrspace(1)* %b, i64 %indvars.iv
+  %load = load half, half addrspace(1)* %arrayidx, align 4
+  %mul = fmul half %load, 3.0
+  %arrayidx2 = getelementptr inbounds half, half addrspace(1)* %a, i64 %indvars.iv
+  store half %mul, half addrspace(1)* %arrayidx2, align 4
+  %indvars.iv.next = add i64 %indvars.iv, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+  %exitcond = icmp eq i32 %lftr.wideiv, 1024
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:                                          ; preds = %for.body, %entry
+  ret void
+}
+
+attributes #0 = { nounwind }
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6314,6 +6314,13 @@
     return None;
   }
 
+  if (Legal->getRuntimePointerChecking()->Need && TTI.hasBranchDivergence()) {
+    // TODO: It may by useful to do since it's still likely to be dynamically
+    // uniform if the target can skip.
+    DEBUG(dbgs() << "LV: Not inserting runtime ptr check for divergent target");
+    return None;
+  }
+
   if (!OptForSize) // Remaining checks deal with scalar loop when OptForSize.
     return computeFeasibleMaxVF(OptForSize);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32730.97378.patch
Type: text/x-patch
Size: 2123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170502/def1f05b/attachment-0001.bin>


More information about the llvm-commits mailing list