[PATCH] D59050: [InterleavedAccessAnalysis] Use unordered_map to avoid tombstone insertion.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 14:04:57 PST 2019


fhahn created this revision.
fhahn added reviewers: Ayal, anna, hsaito, efriedma, dorit.
Herald added a project: LLVM.

Nothing prevents a key to the Members map being a tombstone/empty
special value. By using unordered_map, we avoid limiting the keys to
exclude tombstone/empty key values. Alternatively we could avoid adding
tombstone/empty key values to interleave groups, but there should be no
performance impact by not using DenseMap.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11638


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59050

Files:
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/test/Transforms/LoopVectorize/X86/interleaved-accesses-large-gap.ll


Index: llvm/test/Transforms/LoopVectorize/X86/interleaved-accesses-large-gap.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/X86/interleaved-accesses-large-gap.ll
+++ llvm/test/Transforms/LoopVectorize/X86/interleaved-accesses-large-gap.ll
@@ -38,3 +38,33 @@
 for.cond.cleanup:                                 ; preds = %for.body
   ret void
 }
+
+; Test from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11638
+define void @test2() {
+; CHECK-LABEL: @test2
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label %for.body
+
+; CHECK-LABEL: for.body:
+; CHECK: store i32
+; CHECK: store i32
+; CHECK-NOT: store
+;
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %indvars.iv = phi i64 [ 1, %entry ], [ %0, %for.body ]
+  %0 = add nsw i64 %indvars.iv, -1
+  %arrayidx = getelementptr inbounds [3 x i32], [3 x i32]* undef, i64 0, i64 %0
+  %G2 = getelementptr i32, i32* %arrayidx, i64 %0
+  %B = sub i32 -2147483648, -2147483648
+  %G9 = getelementptr i32, i32* %G2, i32 -2147483648
+  %G1 = getelementptr i32, i32* %arrayidx, i64 %0
+  store i32 %B, i32* %G1
+  store i32 %B, i32* %G9
+  br i1 false, label %for.body, label %for.cond.cleanup
+
+for.cond.cleanup:                                 ; preds = %for.body
+  ret void
+}
Index: llvm/include/llvm/Analysis/VectorUtils.h
===================================================================
--- llvm/include/llvm/Analysis/VectorUtils.h
+++ llvm/include/llvm/Analysis/VectorUtils.h
@@ -19,6 +19,8 @@
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/Support/CheckedArithmetic.h"
 
+#include <unordered_map>
+
 namespace llvm {
 
 template <typename T> class ArrayRef;
@@ -369,7 +371,9 @@
   uint32_t Factor; // Interleave Factor.
   bool Reverse;
   uint32_t Align;
-  DenseMap<int32_t, InstTy *> Members;
+  // We are using unordered_map instead of DenseMap to avoid limiting the key range
+  // by tombstone/empty key values.
+  std::unordered_map<int32_t, InstTy *> Members;
   int32_t SmallestKey = 0;
   int32_t LargestKey = 0;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59050.189588.patch
Type: text/x-patch
Size: 2117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190306/dc4941ce/attachment.bin>


More information about the llvm-commits mailing list