From 6ee46702d5710b3542e37a48adcf933655d0ca8d Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sun, 11 Mar 2018 16:45:31 +0000 Subject: [PATCH] [InstCombine] add tests for casted sign-bit cmp (PR36682); NFC llvm-svn: 327243 --- llvm/test/Transforms/InstCombine/icmp.ll | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 22f5ba5..2e6d4ae 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -3305,12 +3305,37 @@ define i1 @PR35794(i32* %a) { ; Don't crash by assuming the compared values are integers. define <2 x i1> @PR36583(<2 x i8*>) { ; CHECK-LABEL: @PR36583( -; CHECK-NEXT: entry: ; CHECK-NEXT: [[RES:%.*]] = icmp eq <2 x i8*> %0, zeroinitializer ; CHECK-NEXT: ret <2 x i1> [[RES]] ; -entry: %cast = ptrtoint <2 x i8*> %0 to <2 x i64> %res = icmp eq <2 x i64> %cast, zeroinitializer ret <2 x i1> %res } + +define i1 @doublecast_signbit_set(i64 %x) { +; CHECK-LABEL: @doublecast_signbit_set( +; CHECK-NEXT: [[F:%.*]] = sitofp i64 [[X:%.*]] to float +; CHECK-NEXT: [[I:%.*]] = bitcast float [[F]] to i32 +; CHECK-NEXT: [[R:%.*]] = icmp slt i32 [[I]], 0 +; CHECK-NEXT: ret i1 [[R]] +; + %f = sitofp i64 %x to float + %i = bitcast float %f to i32 + %r = icmp slt i32 %i, 0 + ret i1 %r +} + +define <3 x i1> @doublecast_signbit_clear(<3 x i32> %x) { +; CHECK-LABEL: @doublecast_signbit_clear( +; CHECK-NEXT: [[F:%.*]] = sitofp <3 x i32> [[X:%.*]] to <3 x double> +; CHECK-NEXT: [[I:%.*]] = bitcast <3 x double> [[F]] to <3 x i64> +; CHECK-NEXT: [[R:%.*]] = icmp sgt <3 x i64> [[I]], +; CHECK-NEXT: ret <3 x i1> [[R]] +; + %f = sitofp <3 x i32> %x to <3 x double> + %i = bitcast <3 x double> %f to <3 x i64> + %r = icmp sgt <3 x i64> %i, + ret <3 x i1> %r +} + -- 2.7.4