From 276a6b88898a9847d6b401b769e53fb3af6e7b78 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Tue, 28 Jan 2020 13:21:36 -0500 Subject: [PATCH] [InstCombine] add tests for cmp with splat operand and splat constant; NFC See PR44588: https://bugs.llvm.org/show_bug.cgi?id=44588 --- llvm/test/Transforms/InstCombine/icmp-vec.ll | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/icmp-vec.ll b/llvm/test/Transforms/InstCombine/icmp-vec.ll index 8f4cfdb..76bfbfa 100644 --- a/llvm/test/Transforms/InstCombine/icmp-vec.ll +++ b/llvm/test/Transforms/InstCombine/icmp-vec.ll @@ -289,3 +289,81 @@ define <2 x i1> @same_shuffle_inputs_icmp_extra_use3(<4 x i8> %x, <4 x i8> %y) { ret <2 x i1> %cmp } +define <4 x i1> @splat_icmp(<4 x i8> %x) { +; CHECK-LABEL: @splat_icmp( +; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], +; CHECK-NEXT: ret <4 x i1> [[CMP]] +; + %splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> + %cmp = icmp sgt <4 x i8> %splatx, + ret <4 x i1> %cmp +} + +define <4 x i1> @splat_icmp_undef(<4 x i8> %x) { +; CHECK-LABEL: @splat_icmp_undef( +; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> +; CHECK-NEXT: [[CMP:%.*]] = icmp ult <4 x i8> [[SPLATX]], +; CHECK-NEXT: ret <4 x i1> [[CMP]] +; + %splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> + %cmp = icmp ult <4 x i8> %splatx, + ret <4 x i1> %cmp +} + +define <4 x i1> @splat_icmp_larger_size(<2 x i8> %x) { +; CHECK-LABEL: @splat_icmp_larger_size( +; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> undef, <4 x i32> +; CHECK-NEXT: [[CMP:%.*]] = icmp eq <4 x i8> [[SPLATX]], +; CHECK-NEXT: ret <4 x i1> [[CMP]] +; + %splatx = shufflevector <2 x i8> %x, <2 x i8> undef, <4 x i32> + %cmp = icmp eq <4 x i8> %splatx, + ret <4 x i1> %cmp +} + +define <4 x i1> @splat_fcmp_smaller_size(<5 x float> %x) { +; CHECK-LABEL: @splat_fcmp_smaller_size( +; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <5 x float> [[X:%.*]], <5 x float> undef, <4 x i32> +; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq <4 x float> [[SPLATX]], +; CHECK-NEXT: ret <4 x i1> [[CMP]] +; + %splatx = shufflevector <5 x float> %x, <5 x float> undef, <4 x i32> + %cmp = fcmp oeq <4 x float> %splatx, + ret <4 x i1> %cmp +} + +define <4 x i1> @splat_icmp_extra_use(<4 x i8> %x) { +; CHECK-LABEL: @splat_icmp_extra_use( +; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> +; CHECK-NEXT: call void @use_v4i8(<4 x i8> [[SPLATX]]) +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], +; CHECK-NEXT: ret <4 x i1> [[CMP]] +; + %splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> + call void @use_v4i8(<4 x i8> %splatx) + %cmp = icmp sgt <4 x i8> %splatx, + ret <4 x i1> %cmp +} + +define <4 x i1> @not_splat_icmp(<4 x i8> %x) { +; CHECK-LABEL: @not_splat_icmp( +; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], +; CHECK-NEXT: ret <4 x i1> [[CMP]] +; + %splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> + %cmp = icmp sgt <4 x i8> %splatx, + ret <4 x i1> %cmp +} + +define <4 x i1> @not_splat_icmp2(<4 x i8> %x) { +; CHECK-LABEL: @not_splat_icmp2( +; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], +; CHECK-NEXT: ret <4 x i1> [[CMP]] +; + %splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> + %cmp = icmp sgt <4 x i8> %splatx, + ret <4 x i1> %cmp +} -- 2.7.4