[llvm] 544be70 - [AMDGPU] Skip promote-alloca for insertelement/insertvalue users

Christudasan Devadasan via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 20:07:46 PDT 2021


Author: Christudasan Devadasan
Date: 2021-04-30T08:37:26+05:30
New Revision: 544be708641b2f3d58a1b86ae86c3ba460f41d10

URL: https://github.com/llvm/llvm-project/commit/544be708641b2f3d58a1b86ae86c3ba460f41d10
DIFF: https://github.com/llvm/llvm-project/commit/544be708641b2f3d58a1b86ae86c3ba460f41d10.diff

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

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

Reviewed by: arsenm

Differential Revision: https://reviews.llvm.org/D101562

Added: 
    llvm/test/CodeGen/AMDGPU/skip-promote-alloca-vector-users.ll

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
index 9253775ef84b..3c59612aa7a3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -661,6 +661,11 @@ bool AMDGPUPromoteAllocaImpl::collectUsesWithPtrTypes(
       continue;
     }
 
+    // Do not promote vector/aggregate type instructions. It is hard to track
+    // their users.
+    if (isa<InsertValueInst>(User) || isa<InsertElementInst>(User))
+      return false;
+
     if (!User->getType()->isPointerTy())
       continue;
 

diff  --git a/llvm/test/CodeGen/AMDGPU/skip-promote-alloca-vector-users.ll b/llvm/test/CodeGen/AMDGPU/skip-promote-alloca-vector-users.ll
new file mode 100644
index 000000000000..47b40f7e8b51
--- /dev/null
+++ b/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 <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 { 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 [2 x i16*] %in, [2 x i16*]* undef, align 4
+  ret void
+}
+
+attributes #0 = { nounwind }


        


More information about the llvm-commits mailing list