[PATCH] Fix lint assert on integer vector division

Matt Arsenault Matthew.Arsenault at amd.com
Wed Aug 14 17:51:33 PDT 2013


http://llvm-reviews.chandlerc.com/D1408

Files:
  lib/Analysis/Lint.cpp
  test/Analysis/Lint/check-zero-vector.ll
  test/Analysis/Lint/lit.local.cfg

Index: lib/Analysis/Lint.cpp
===================================================================
--- lib/Analysis/Lint.cpp
+++ lib/Analysis/Lint.cpp
@@ -504,13 +504,14 @@
             "Undefined result: Shift count out of range", &I);
 }
 
-static bool isZero(Value *V, DataLayout *TD) {
+static bool isZero(Value *V, DataLayout *DL) {
   // Assume undef could be zero.
-  if (isa<UndefValue>(V)) return true;
+  if (isa<UndefValue>(V))
+    return true;
 
-  unsigned BitWidth = cast<IntegerType>(V->getType())->getBitWidth();
+  unsigned BitWidth = V->getType()->getScalarType()->getIntegerBitWidth();
   APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
-  ComputeMaskedBits(V, KnownZero, KnownOne, TD);
+  ComputeMaskedBits(V, KnownZero, KnownOne, DL);
   return KnownZero.isAllOnesValue();
 }
 
Index: test/Analysis/Lint/check-zero-vector.ll
===================================================================
--- /dev/null
+++ test/Analysis/Lint/check-zero-vector.ll
@@ -0,0 +1,21 @@
+; RUN: opt -lint < %s
+
+define <2 x i32> @use_vector_sdiv(<2 x i32> %a) nounwind {
+  %b = sdiv <2 x i32> %a, <i32 5, i32 8>
+  ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_srem(<2 x i32> %a) nounwind {
+  %b = srem <2 x i32> %a, <i32 5, i32 8>
+  ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_udiv(<2 x i32> %a) nounwind {
+  %b = udiv <2 x i32> %a, <i32 5, i32 8>
+  ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_urem(<2 x i32> %a) nounwind {
+  %b = urem <2 x i32> %a, <i32 5, i32 8>
+  ret <2 x i32> %b
+}
\ No newline at end of file
Index: test/Analysis/Lint/lit.local.cfg
===================================================================
--- /dev/null
+++ test/Analysis/Lint/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.ll']
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1408.1.patch
Type: text/x-patch
Size: 1752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130814/fb1018a1/attachment.bin>


More information about the llvm-commits mailing list