From f226cc250dc8fe1dc2f5392d18cb0f91680254c8 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 20 Jul 2019 21:33:50 +0000 Subject: [PATCH] [NFC][InstCombine] Add srem-by-signbit tests - still can fold to bittest https://rise4fun.com/Alive/IIeS git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366642 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/rem.ll | 48 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/test/Transforms/InstCombine/rem.ll b/test/Transforms/InstCombine/rem.ll index 200e0389fd7..c5adeb77e53 100644 --- a/test/Transforms/InstCombine/rem.ll +++ b/test/Transforms/InstCombine/rem.ll @@ -367,8 +367,8 @@ define i32 @test16(i32 %x, i32 %y) { define i32 @test17(i32 %X) { ; CHECK-LABEL: @test17( ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[X:%.*]], 1 -; CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i32 -; CHECK-NEXT: ret i32 [[TMP2]] +; CHECK-NEXT: [[A:%.*]] = zext i1 [[TMP1]] to i32 +; CHECK-NEXT: ret i32 [[A]] ; %A = urem i32 1, %X ret i32 %A @@ -657,6 +657,50 @@ define <2 x i32> @test23(<2 x i32> %A) { ret <2 x i32> %mul } +define i1 @test24(i32 %A) { +; CHECK-LABEL: @test24( +; CHECK-NEXT: [[B:%.*]] = and i32 [[A:%.*]], 2147483647 +; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[B]], 0 +; CHECK-NEXT: ret i1 [[C]] +; + %B = urem i32 %A, 2147483648 ; signbit + %C = icmp ne i32 %B, 0 + ret i1 %C +} + +define <2 x i1> @test24_vec(<2 x i32> %A) { +; CHECK-LABEL: @test24_vec( +; CHECK-NEXT: [[B:%.*]] = and <2 x i32> [[A:%.*]], +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %B = urem <2 x i32> %A, + %C = icmp ne <2 x i32> %B, zeroinitializer + ret <2 x i1> %C +} + +define i1 @test25(i32 %A) { +; CHECK-LABEL: @test25( +; CHECK-NEXT: [[B:%.*]] = srem i32 [[A:%.*]], -2147483648 +; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[B]], 0 +; CHECK-NEXT: ret i1 [[C]] +; + %B = srem i32 %A, 2147483648 ; signbit + %C = icmp ne i32 %B, 0 + ret i1 %C +} + +define <2 x i1> @test25_vec(<2 x i32> %A) { +; CHECK-LABEL: @test25_vec( +; CHECK-NEXT: [[B:%.*]] = srem <2 x i32> [[A:%.*]], +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %B = srem <2 x i32> %A, + %C = icmp ne <2 x i32> %B, zeroinitializer + ret <2 x i1> %C +} + ; FP division-by-zero is not UB. define double @PR34870(i1 %cond, double %x, double %y) { -- 2.50.0