From 94944f800c1242e0375b4a658820a366445e7bc1 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 29 Dec 2022 14:51:30 -0500 Subject: [PATCH] [InstSimplify] add tests for select-of-bool; NFC --- .../test/Transforms/InstSimplify/select-logical.ll | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/llvm/test/Transforms/InstSimplify/select-logical.ll b/llvm/test/Transforms/InstSimplify/select-logical.ll index 70e5a55..1d1ee58 100644 --- a/llvm/test/Transforms/InstSimplify/select-logical.ll +++ b/llvm/test/Transforms/InstSimplify/select-logical.ll @@ -553,3 +553,39 @@ define i1 @select_and_same_op_negative(i1 %x, i1 %y, i1 %z) { %r = select i1 %a, i1 %x, i1 %z ret i1 %r } + +define i1 @and_same_op(i1 %x) { +; CHECK-LABEL: @and_same_op( +; CHECK-NEXT: [[R:%.*]] = select i1 [[X:%.*]], i1 [[X]], i1 false +; CHECK-NEXT: ret i1 [[R]] +; + %r = select i1 %x, i1 %x, i1 false + ret i1 %r +} + +define <2 x i1> @or_same_op(<2 x i1> %x) { +; CHECK-LABEL: @or_same_op( +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[X:%.*]], <2 x i1> , <2 x i1> [[X]] +; CHECK-NEXT: ret <2 x i1> [[R]] +; + %r = select <2 x i1> %x, <2 x i1> , <2 x i1> %x + ret <2 x i1> %r +} + +define <2 x i1> @always_true_same_op(<2 x i1> %x) { +; CHECK-LABEL: @always_true_same_op( +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[X:%.*]], <2 x i1> [[X]], <2 x i1> +; CHECK-NEXT: ret <2 x i1> [[R]] +; + %r = select <2 x i1> %x, <2 x i1> %x, <2 x i1> + ret <2 x i1> %r +} + +define i1 @always_false_same_op(i1 %x) { +; CHECK-LABEL: @always_false_same_op( +; CHECK-NEXT: [[R:%.*]] = select i1 [[X:%.*]], i1 false, i1 [[X]] +; CHECK-NEXT: ret i1 [[R]] +; + %r = select i1 %x, i1 false, i1 %x + ret i1 %r +} -- 2.7.4