From f932f5727359c8f7481906a3c1622f1a3de6f065 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Fri, 16 Aug 2019 22:40:06 +0000 Subject: [PATCH] [InstCombine][NFC] Revisit tests in reuse-constant-from-select-in-icmp.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369163 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../reuse-constant-from-select-in-icmp.ll | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll b/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll index 127cdf7e518..df8b79e7a0b 100644 --- a/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll +++ b/test/Transforms/InstCombine/reuse-constant-from-select-in-icmp.ll @@ -211,41 +211,41 @@ define i32 @p15_commutativity2(i32 %x, i32 %y) { define <2 x i32> @n17_ult_zero(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @n17_ult_zero( ; CHECK-NEXT: [[T:%.*]] = icmp ult <2 x i32> [[X:%.*]], -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t = icmp ult <2 x i32> %x, - %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> + %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> ret <2 x i32> %r } define <2 x i32> @n18_ugt_allones(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @n18_ugt_allones( ; CHECK-NEXT: [[T:%.*]] = icmp ugt <2 x i32> [[X:%.*]], -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t = icmp ugt <2 x i32> %x, - %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> + %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> ret <2 x i32> %r } define <2 x i32> @n19_slt_int_min(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @n19_slt_int_min( ; CHECK-NEXT: [[T:%.*]] = icmp slt <2 x i32> [[X:%.*]], -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t = icmp slt <2 x i32> %x, - %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> + %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> ret <2 x i32> %r } define <2 x i32> @n20_sgt_int_max(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @n20_sgt_int_max( ; CHECK-NEXT: [[T:%.*]] = icmp sgt <2 x i32> [[X:%.*]], -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[T]], <2 x i32> [[Y:%.*]], <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t = icmp sgt <2 x i32> %x, - %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> + %r = select <2 x i1> %t, <2 x i32> %y, <2 x i32> ret <2 x i32> %r } @@ -296,3 +296,25 @@ define i32 @n24_ult_65534(i32 %x, i32 %y) { %r = select i1 %t, i32 %y, i32 65535 ret i32 %r } + +; If we already have a match, it's good enough. +define i32 @n25_all_good0(i32 %x, i32 %y) { +; CHECK-LABEL: @n25_all_good0( +; CHECK-NEXT: [[T:%.*]] = icmp ult i32 [[X:%.*]], 65536 +; CHECK-NEXT: [[R:%.*]] = select i1 [[T]], i32 65535, i32 65536 +; CHECK-NEXT: ret i32 [[R]] +; + %t = icmp ult i32 %x, 65536 + %r = select i1 %t, i32 65535, i32 65536 + ret i32 %r +} +define i32 @n26_all_good1(i32 %x, i32 %y) { +; CHECK-LABEL: @n26_all_good1( +; CHECK-NEXT: [[T:%.*]] = icmp ult i32 [[X:%.*]], 65536 +; CHECK-NEXT: [[R:%.*]] = select i1 [[T]], i32 65536, i32 65535 +; CHECK-NEXT: ret i32 [[R]] +; + %t = icmp ult i32 %x, 65536 + %r = select i1 %t, i32 65536, i32 65535 + ret i32 %r +} -- 2.40.0