[PATCH] D25849: [GVN] Prevent load coercion with irregular vector types

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 20 16:51:24 PDT 2016


davide created this revision.
davide added reviewers: RKSimon, dberlin.
davide added a subscriber: llvm-commits.

See https://llvm.org/bugs/show_bug.cgi?id=28879 for reference


https://reviews.llvm.org/D25849

Files:
  lib/Transforms/Scalar/GVN.cpp
  test/Transforms/GVN/i7vector.ll


Index: test/Transforms/GVN/i7vector.ll
===================================================================
--- /dev/null
+++ test/Transforms/GVN/i7vector.ll
@@ -0,0 +1,16 @@
+; RUN: opt -gvn %s -S -o - | FileCheck %s
+
+define void @f() {
+entry:
+  %a = alloca <7 x i1>, align 2
+  store <7 x i1> undef, <7 x i1>* %a, align 2
+  %0 = getelementptr inbounds <7 x i1>, <7 x i1>* %a, i64 0, i64 0
+  %val = load i1, i1* %0, align 2
+  br i1 %val, label %cond.true, label %cond.false
+
+cond.true:
+  ret void
+
+cond.false:
+  ret void
+}
Index: lib/Transforms/Scalar/GVN.cpp
===================================================================
--- lib/Transforms/Scalar/GVN.cpp
+++ lib/Transforms/Scalar/GVN.cpp
@@ -718,6 +718,13 @@
         DL.getTypeSizeInBits(LoadTy))
     return false;
 
+  // Prevent load coercion with irregular vector types (e.g. <7 x i1>).
+  // Other parts of the code don't deal with them very well and we're
+  // going to crash later now anyway.
+  if ((((DL.getTypeSizeInBits(StoredVal->getType()) + 7) / 8) * 8) !=
+      DL.getTypeSizeInBits(StoredVal->getType()))
+    return false;
+
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25849.75369.patch
Type: text/x-patch
Size: 1138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161020/d503ea71/attachment.bin>


More information about the llvm-commits mailing list