[PATCH] D101562: [AMDGPU] Skip promote-alloca for insertelement/insertvalue users

Christudasan Devadasan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 12:13:31 PDT 2021


cdevadas created this revision.
cdevadas added a reviewer: arsenm.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
cdevadas requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

It is difficult to track the users of vector and aggregate types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101562

Files:
  llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
  llvm/test/CodeGen/AMDGPU/skip-promote-alloca-vector-users.ll


Index: llvm/test/CodeGen/AMDGPU/skip-promote-alloca-vector-users.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/skip-promote-alloca-vector-users.ll
@@ -0,0 +1,38 @@
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s
+
+; Do not promote an alloca with users of vector/aggregate type.
+
+; CHECK-LABEL: @test_insertelement(
+; CHECK:  %alloca = alloca i16
+; CHECK-NEXT:  insertelement <2 x i16*> undef, i16* %alloca, i32 0
+define amdgpu_kernel void @test_insertelement() #0 {
+entry:
+  %alloca = alloca i16, align 4
+  %in = insertelement <2 x i16*> undef, i16* %alloca, i32 0
+  store volatile <2 x i16*> %in, <2 x i16*>* undef, align 4
+  ret void
+}
+
+; CHECK-LABEL: @test_insertvalue(
+; CHECK:  %alloca = alloca i16
+; CHECK-NEXT:  insertvalue { i16* } undef, i16* %alloca, 0
+define amdgpu_kernel void @test_insertvalue() #0 {
+entry:
+  %alloca = alloca i16, align 4
+  %in = insertvalue { i16* } undef, i16* %alloca, 0
+  store volatile { i16* } %in, { i16* }* undef, align 4
+  ret void
+}
+
+; CHECK-LABEL: @test_insertvalue_array(
+; CHECK:  %alloca = alloca i16
+; CHECK-NEXT:  insertvalue [2 x i16*] undef, i16* %alloca, 0
+define amdgpu_kernel void @test_insertvalue_array() #0 {
+entry:
+  %alloca = alloca i16, align 4
+  %in = insertvalue [2 x i16*] undef, i16* %alloca, 0
+  store volatile [2 x i16*] %in, [2 x i16*]* undef, align 4
+  ret void
+}
+
+attributes #0 = { nounwind }
Index: llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -608,6 +608,11 @@
     if (is_contained(WorkList, User))
       continue;
 
+    // Do not promote instructions of vector type. It is hard to track their
+    // users.
+    if (isa<InsertValueInst>(User) || isa<InsertElementInst>(User))
+      return false;
+
     if (CallInst *CI = dyn_cast<CallInst>(User)) {
       if (!isCallPromotable(CI))
         return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101562.341604.patch
Type: text/x-patch
Size: 2098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210429/43a1b8f8/attachment.bin>


More information about the llvm-commits mailing list