From a46bcbec583b5ac8256c0698efe77d04789e1b92 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 25 Jun 2018 18:27:14 +0000 Subject: [PATCH] [InstSimplify] add tests for div/rem with bool divisor; NFC llvm-svn: 335509 --- llvm/test/Transforms/InstSimplify/div.ll | 22 ++++++++++++++++++++++ llvm/test/Transforms/InstSimplify/rem.ll | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/llvm/test/Transforms/InstSimplify/div.ll b/llvm/test/Transforms/InstSimplify/div.ll index 146112a48c6b..4cd2bae2cfac 100644 --- a/llvm/test/Transforms/InstSimplify/div.ll +++ b/llvm/test/Transforms/InstSimplify/div.ll @@ -95,6 +95,28 @@ define <2 x i1> @udiv_bool_vec(<2 x i1> %x, <2 x i1> %y) { ret <2 x i1> %div } +define i32 @zext_bool_udiv_divisor(i1 %x, i32 %y) { +; CHECK-LABEL: @zext_bool_udiv_divisor( +; CHECK-NEXT: [[EXT:%.*]] = zext i1 [[X:%.*]] to i32 +; CHECK-NEXT: [[R:%.*]] = udiv i32 [[Y:%.*]], [[EXT]] +; CHECK-NEXT: ret i32 [[R]] +; + %ext = zext i1 %x to i32 + %r = udiv i32 %y, %ext + ret i32 %r +} + +define <2 x i32> @zext_bool_sdiv_divisor_vec(<2 x i1> %x, <2 x i32> %y) { +; CHECK-LABEL: @zext_bool_sdiv_divisor_vec( +; CHECK-NEXT: [[EXT:%.*]] = zext <2 x i1> [[X:%.*]] to <2 x i32> +; CHECK-NEXT: [[R:%.*]] = sdiv <2 x i32> [[Y:%.*]], [[EXT]] +; CHECK-NEXT: ret <2 x i32> [[R]] +; + %ext = zext <2 x i1> %x to <2 x i32> + %r = sdiv <2 x i32> %y, %ext + ret <2 x i32> %r +} + define i32 @udiv_dividend_known_smaller_than_constant_divisor(i32 %x) { ; CHECK-LABEL: @udiv_dividend_known_smaller_than_constant_divisor( ; CHECK-NEXT: ret i32 0 diff --git a/llvm/test/Transforms/InstSimplify/rem.ll b/llvm/test/Transforms/InstSimplify/rem.ll index 205fdedf246e..cf586bf9153d 100644 --- a/llvm/test/Transforms/InstSimplify/rem.ll +++ b/llvm/test/Transforms/InstSimplify/rem.ll @@ -95,6 +95,28 @@ define <2 x i1> @urem_bool_vec(<2 x i1> %x, <2 x i1> %y) { ret <2 x i1> %rem } +define <2 x i32> @zext_bool_urem_divisor_vec(<2 x i1> %x, <2 x i32> %y) { +; CHECK-LABEL: @zext_bool_urem_divisor_vec( +; CHECK-NEXT: [[EXT:%.*]] = zext <2 x i1> [[X:%.*]] to <2 x i32> +; CHECK-NEXT: [[R:%.*]] = urem <2 x i32> [[Y:%.*]], [[EXT]] +; CHECK-NEXT: ret <2 x i32> [[R]] +; + %ext = zext <2 x i1> %x to <2 x i32> + %r = urem <2 x i32> %y, %ext + ret <2 x i32> %r +} + +define i32 @zext_bool_srem_divisor(i1 %x, i32 %y) { +; CHECK-LABEL: @zext_bool_srem_divisor( +; CHECK-NEXT: [[EXT:%.*]] = zext i1 [[X:%.*]] to i32 +; CHECK-NEXT: [[R:%.*]] = srem i32 [[Y:%.*]], [[EXT]] +; CHECK-NEXT: ret i32 [[R]] +; + %ext = zext i1 %x to i32 + %r = srem i32 %y, %ext + ret i32 %r +} + define i32 @select1(i32 %x, i1 %b) { ; CHECK-LABEL: @select1( ; CHECK-NEXT: ret i32 0