From 46756ef2bd43735132a74e3ae056ce0f2fedbf5c Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 10 Mar 2017 00:55:29 +0000 Subject: [PATCH] [x86] add tests for vec div/rem with 0 element in divisor; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297433 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/X86/div-rem-simplify.ll | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/CodeGen/X86/div-rem-simplify.ll b/test/CodeGen/X86/div-rem-simplify.ll index b099028fe22..c0ce3e57505 100644 --- a/test/CodeGen/X86/div-rem-simplify.ll +++ b/test/CodeGen/X86/div-rem-simplify.ll @@ -147,3 +147,46 @@ define <4 x i32> @sel_sdiv0_vec(i1 %cond) { ret <4 x i32> %div } +; If any element of a constant divisor vector is zero, the whole op is undef. + +define <4 x i32> @sdiv0elt_vec(<4 x i32> %x) { +; CHECK-LABEL: sdiv0elt_vec: +; CHECK: # BB#0: +; CHECK-NEXT: movaps {{.*#+}} xmm0 = +; CHECK-NEXT: retq + %zero = and <4 x i32> %x, + %some_ones = or <4 x i32> %zero, + %div = sdiv <4 x i32> , %some_ones + ret <4 x i32> %div +} + +define <4 x i32> @udiv0elt_vec(<4 x i32> %x) { +; CHECK-LABEL: udiv0elt_vec: +; CHECK: # BB#0: +; CHECK-NEXT: movaps {{.*#+}} xmm0 = +; CHECK-NEXT: retq + %div = udiv <4 x i32> , + ret <4 x i32> %div +} + +define <4 x i32> @urem0elt_vec(<4 x i32> %x) { +; CHECK-LABEL: urem0elt_vec: +; CHECK: # BB#0: +; CHECK-NEXT: movaps {{.*#+}} xmm0 = +; CHECK-NEXT: retq + %zero = and <4 x i32> %x, + %some_ones = or <4 x i32> %zero, + %rem = urem <4 x i32> , %some_ones + ret <4 x i32> %rem +} + +define <4 x i32> @srem0elt_vec(<4 x i32> %x) { +; CHECK-LABEL: srem0elt_vec: +; CHECK: # BB#0: +; CHECK-NEXT: movl $-2, %eax +; CHECK-NEXT: movd %eax, %xmm0 +; CHECK-NEXT: retq + %rem = srem <4 x i32> , + ret <4 x i32> %rem +} + -- 2.50.1