aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis/Lint
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2013-08-26 23:29:33 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2013-08-26 23:29:33 +0000
commite3e5f77d77e7ccc5c966e242f0cd0ccf6d3dae7f (patch)
tree34aefd1477e1643f7f40a3c7ba5f51d622b654ac /test/Analysis/Lint
parent63ae7c9aeca10f1028bb7232672ccefb2343ba08 (diff)
downloadexternal_llvm-e3e5f77d77e7ccc5c966e242f0cd0ccf6d3dae7f.zip
external_llvm-e3e5f77d77e7ccc5c966e242f0cd0ccf6d3dae7f.tar.gz
external_llvm-e3e5f77d77e7ccc5c966e242f0cd0ccf6d3dae7f.tar.bz2
Fix lint assert on integer vector division
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189290 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/Lint')
-rw-r--r--test/Analysis/Lint/check-zero-divide.ll78
-rw-r--r--test/Analysis/Lint/lit.local.cfg1
2 files changed, 79 insertions, 0 deletions
diff --git a/test/Analysis/Lint/check-zero-divide.ll b/test/Analysis/Lint/check-zero-divide.ll
new file mode 100644
index 0000000..f4e79ed
--- /dev/null
+++ b/test/Analysis/Lint/check-zero-divide.ll
@@ -0,0 +1,78 @@
+; RUN: opt -lint -disable-output %s 2>&1 | FileCheck %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
+}
+
+define i32 @use_sdiv_by_zero(i32 %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv i32 %a, 0
+ %b = sdiv i32 %a, 0
+ ret i32 %b
+}
+
+define i32 @use_sdiv_by_zeroinitializer(i32 %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv i32 %a, 0
+ %b = sdiv i32 %a, zeroinitializer
+ ret i32 %b
+}
+
+define <2 x i32> @use_vector_sdiv_by_zero_x(<2 x i32> %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 0, i32 5>
+ %b = sdiv <2 x i32> %a, <i32 0, i32 5>
+ ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_sdiv_by_zero_y(<2 x i32> %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 4, i32 0>
+ %b = sdiv <2 x i32> %a, <i32 4, i32 0>
+ ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_sdiv_by_zero_xy(<2 x i32> %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv <2 x i32> %a, zeroinitializer
+ %b = sdiv <2 x i32> %a, <i32 0, i32 0>
+ ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_sdiv_by_undef_x(<2 x i32> %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 undef, i32 5>
+ %b = sdiv <2 x i32> %a, <i32 undef, i32 5>
+ ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_sdiv_by_undef_y(<2 x i32> %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv <2 x i32> %a, <i32 5, i32 undef>
+ %b = sdiv <2 x i32> %a, <i32 5, i32 undef>
+ ret <2 x i32> %b
+}
+
+define <2 x i32> @use_vector_sdiv_by_undef_xy(<2 x i32> %a) nounwind {
+; CHECK: Undefined behavior: Division by zero
+; CHECK-NEXT: %b = sdiv <2 x i32> %a, undef
+ %b = sdiv <2 x i32> %a, <i32 undef, i32 undef>
+ ret <2 x i32> %b
+}
+
diff --git a/test/Analysis/Lint/lit.local.cfg b/test/Analysis/Lint/lit.local.cfg
new file mode 100644
index 0000000..c6106e4
--- /dev/null
+++ b/test/Analysis/Lint/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.ll']