summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorZvi Rackover <zvi.rackover@intel.com>2018-01-24 17:22:00 +0000
committerZvi Rackover <zvi.rackover@intel.com>2018-01-24 17:22:00 +0000
commit51f0d64b9cd847f7637e5c480016a6f6e9fad173 (patch)
tree5e6833ea3af0816376021896ee7cd5be6b1dfb54 /llvm/test/Transforms
parent262ed0ecd715afe3e1c0194a80317e3d342ebc5c (diff)
downloadbcm5719-llvm-51f0d64b9cd847f7637e5c480016a6f6e9fad173.tar.gz
bcm5719-llvm-51f0d64b9cd847f7637e5c480016a6f6e9fad173.zip
InstSimplify: If divisor element is undef simplify to undef
Summary: If any vector divisor element is undef, we can arbitrarily choose it be zero which would make the div/rem an undef value by definition. Reviewers: spatel, reames Reviewed By: spatel Subscribers: magabari, llvm-commits Differential Revision: https://reviews.llvm.org/D42485 llvm-svn: 323343
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstSimplify/div.ll16
-rw-r--r--llvm/test/Transforms/InstSimplify/rem.ll16
2 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/div.ll b/llvm/test/Transforms/InstSimplify/div.ll
index a1cc8572724..1eb767e17bf 100644
--- a/llvm/test/Transforms/InstSimplify/div.ll
+++ b/llvm/test/Transforms/InstSimplify/div.ll
@@ -34,6 +34,22 @@ define <2 x i8> @udiv_zero_elt_vec(<2 x i8> %x) {
ret <2 x i8> %div
}
+define <2 x i8> @sdiv_undef_elt_vec(<2 x i8> %x) {
+; CHECK-LABEL: @sdiv_undef_elt_vec(
+; CHECK-NEXT: ret <2 x i8> undef
+;
+ %div = sdiv <2 x i8> %x, <i8 -42, i8 undef>
+ ret <2 x i8> %div
+}
+
+define <2 x i8> @udiv_undef_elt_vec(<2 x i8> %x) {
+; CHECK-LABEL: @udiv_undef_elt_vec(
+; CHECK-NEXT: ret <2 x i8> undef
+;
+ %div = udiv <2 x i8> %x, <i8 undef, i8 42>
+ ret <2 x i8> %div
+}
+
; Division-by-zero is undef. UB in any vector lane means the whole op is undef.
; Thus, we can simplify this: if any element of 'y' is 0, we can do anything.
; Therefore, assume that all elements of 'y' must be 1.
diff --git a/llvm/test/Transforms/InstSimplify/rem.ll b/llvm/test/Transforms/InstSimplify/rem.ll
index a015d4c43e0..e1fc6684cf9 100644
--- a/llvm/test/Transforms/InstSimplify/rem.ll
+++ b/llvm/test/Transforms/InstSimplify/rem.ll
@@ -35,6 +35,22 @@ define <2 x i8> @urem_zero_elt_vec(<2 x i8> %x) {
ret <2 x i8> %rem
}
+define <2 x i8> @srem_undef_elt_vec(<2 x i8> %x) {
+; CHECK-LABEL: @srem_undef_elt_vec(
+; CHECK-NEXT: ret <2 x i8> undef
+;
+ %rem = srem <2 x i8> %x, <i8 -42, i8 undef>
+ ret <2 x i8> %rem
+}
+
+define <2 x i8> @urem_undef_elt_vec(<2 x i8> %x) {
+; CHECK-LABEL: @urem_undef_elt_vec(
+; CHECK-NEXT: ret <2 x i8> undef
+;
+ %rem = urem <2 x i8> %x, <i8 undef, i8 42>
+ ret <2 x i8> %rem
+}
+
; Division-by-zero is undef. UB in any vector lane means the whole op is undef.
; Thus, we can simplify this: if any element of 'y' is 0, we can do anything.
; Therefore, assume that all elements of 'y' must be 1.
OpenPOWER on IntegriCloud