[PATCH] D65480: [AMDGPU] Fix for vectorizer crash with pointers of different size

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 15:30:08 PDT 2019


rampitec created this revision.
rampitec added reviewers: arsenm, kzhuravl.
Herald added subscribers: javed.absar, t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely.

When vectorizer strips pointers it can eventually end up with
pointers of two different sizes, then SCEV will crash.


https://reviews.llvm.org/D65480

Files:
  lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
  test/CodeGen/AMDGPU/vect-ptr-ptr-size-mismatch.ll


Index: test/CodeGen/AMDGPU/vect-ptr-ptr-size-mismatch.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AMDGPU/vect-ptr-ptr-size-mismatch.ll
@@ -0,0 +1,26 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+
+%struct._globalized_locals_ty = type { [64 x i32], [64 x i32*], [64 x i32*], [64 x i32*] }
+
+ at execution_param = external local_unnamed_addr addrspace(3) externally_initialized global i32, align 4
+
+; GCN-LABEL: {{^}}test:
+; GCN: s_cbranch
+; GCN: s_endpgm
+define amdgpu_kernel void @test() #0 {
+entry:
+  br i1 undef, label %.worker, label %.mastercheck
+
+.worker:                                          ; preds = %entry
+  ret void
+
+.mastercheck:                                     ; preds = %entry
+  %tmp = load i32, i32 addrspace(3)* @execution_param, align 4
+  %tmp3 = and i32 %tmp, 1
+  %tmp4 = icmp eq i32 %tmp3, 0
+  %tmp7 = select i1 %tmp4, i32** null, i32** getelementptr (%struct._globalized_locals_ty, %struct._globalized_locals_ty* null, i64 0, i32 1, i64 undef)
+  %tmp9 = select i1 %tmp4, i32** addrspacecast (i32* addrspace(5)* null to i32**), i32** null
+  store i32* undef, i32** %tmp9, align 8
+  store i32* undef, i32** %tmp7, align 8
+  unreachable
+}
Index: lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
@@ -344,6 +344,10 @@
   PtrA = PtrA->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetA);
   PtrB = PtrB->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetB);
 
+  if (DL.getTypeStoreSizeInBits(PtrA->getType()) != PtrBitWidth ||
+      DL.getTypeStoreSizeInBits(PtrB->getType()) != PtrBitWidth)
+    return false;
+
   APInt OffsetDelta = OffsetB - OffsetA;
 
   // Check if they are based on the same pointer. That makes the offsets


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65480.212455.patch
Type: text/x-patch
Size: 1980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190730/c82566ce/attachment-0001.bin>


More information about the llvm-commits mailing list